// generated with brms 2.19.0
functions {
}
data {
  int<lower=1> N;  // total number of observations
  vector[N] Y;  // response variable
  int<lower=1> K_ult;  // number of population-level effects
  matrix[N, K_ult] X_ult;  // population-level design matrix
  int<lower=1> K_omega;  // number of population-level effects
  matrix[N, K_omega] X_omega;  // population-level design matrix
  int<lower=1> K_theta;  // number of population-level effects
  matrix[N, K_theta] X_theta;  // population-level design matrix
  // covariate vectors for non-linear functions
  int C_1[N];
  // data for group-level effects of ID 1
  int<lower=1> N_1;  // number of grouping levels
  int<lower=1> M_1;  // number of coefficients per level
  int<lower=1> J_1[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_1_ult_1;
  int prior_only;  // should the likelihood be ignored?
}
transformed data {
}
parameters {
  vector[K_ult] b_ult;  // population-level effects
  vector[K_omega] b_omega;  // population-level effects
  vector[K_theta] b_theta;  // population-level effects
  real<lower=0> sigma;  // dispersion parameter
  vector<lower=0>[M_1] sd_1;  // group-level standard deviations
  vector[N_1] z_1[M_1];  // standardized group-level effects
}
transformed parameters {
  vector[N_1] r_1_ult_1;  // actual group-level effects
  real lprior = 0;  // prior contributions to the log posterior
  r_1_ult_1 = (sd_1[1] * (z_1[1]));
  lprior += normal_lpdf(b_ult | 5000, 1000);
  lprior += normal_lpdf(b_omega | 1, 2);
  lprior += normal_lpdf(b_theta | 45, 10);
  lprior += student_t_lpdf(sigma | 3, 0, 1963.7)
    - 1 * student_t_lccdf(0 | 3, 0, 1963.7);
  lprior += student_t_lpdf(sd_1 | 3, 0, 1963.7)
    - 1 * student_t_lccdf(0 | 3, 0, 1963.7);
}
model {
  // likelihood including constants
  if (!prior_only) {
    // initialize linear predictor term
    vector[N] nlp_ult = rep_vector(0.0, N);
    // initialize linear predictor term
    vector[N] nlp_omega = rep_vector(0.0, N);
    // initialize linear predictor term
    vector[N] nlp_theta = rep_vector(0.0, N);
    // initialize non-linear predictor term
    vector[N] mu;
    nlp_ult += X_ult * b_ult;
    nlp_omega += X_omega * b_omega;
    nlp_theta += X_theta * b_theta;
    for (n in 1:N) {
      // add more terms to the linear predictor
      nlp_ult[n] += r_1_ult_1[J_1[n]] * Z_1_ult_1[n];
    }
    for (n in 1:N) {
      // compute non-linear predictor values
      mu[n] = (nlp_ult[n] * (1 - exp( - (C_1[n] / nlp_theta[n]) ^ nlp_omega[n])));
    }
    target += normal_lpdf(Y | mu, sigma);
  }
  // priors including constants
  target += lprior;
  target += std_normal_lpdf(z_1[1]);
}
generated quantities {
}