// generated with brms 2.12.0
functions {
}
data {
  int<lower=1> N;  // number of observations
  int<lower=1> N_mpg;  // number of observations
  vector[N_mpg] Y_mpg;  // response variable
  int<lower=1> K_mpg;  // number of population-level effects
  matrix[N_mpg, K_mpg] X_mpg;  // population-level design matrix
  int<lower=1> K_sigma_mpg;  // number of population-level effects
  matrix[N_mpg, K_sigma_mpg] X_sigma_mpg;  // population-level design matrix
  int<lower=1> N_wt;  // number of observations
  vector[N_wt] Y_wt;  // response variable
  int<lower=1> K_wt;  // number of population-level effects
  matrix[N_wt, K_wt] X_wt;  // population-level design matrix
  int<lower=1> K_sigma_wt;  // number of population-level effects
  matrix[N_wt, K_sigma_wt] X_sigma_wt;  // population-level design matrix
  int prior_only;  // should the likelihood be ignored?
}
transformed data {
  int Kc_mpg = K_mpg - 1;
  matrix[N_mpg, Kc_mpg] Xc_mpg;  // centered version of X_mpg without an intercept
  vector[Kc_mpg] means_X_mpg;  // column means of X_mpg before centering
  int Kc_sigma_mpg = K_sigma_mpg - 1;
  matrix[N_mpg, Kc_sigma_mpg] Xc_sigma_mpg;  // centered version of X_sigma_mpg without an intercept
  vector[Kc_sigma_mpg] means_X_sigma_mpg;  // column means of X_sigma_mpg before centering
  int Kc_wt = K_wt - 1;
  matrix[N_wt, Kc_wt] Xc_wt;  // centered version of X_wt without an intercept
  vector[Kc_wt] means_X_wt;  // column means of X_wt before centering
  int Kc_sigma_wt = K_sigma_wt - 1;
  matrix[N_wt, Kc_sigma_wt] Xc_sigma_wt;  // centered version of X_sigma_wt without an intercept
  vector[Kc_sigma_wt] means_X_sigma_wt;  // column means of X_sigma_wt before centering
  for (i in 2:K_mpg) {
    means_X_mpg[i - 1] = mean(X_mpg[, i]);
    Xc_mpg[, i - 1] = X_mpg[, i] - means_X_mpg[i - 1];
  }
  for (i in 2:K_sigma_mpg) {
    means_X_sigma_mpg[i - 1] = mean(X_sigma_mpg[, i]);
    Xc_sigma_mpg[, i - 1] = X_sigma_mpg[, i] - means_X_sigma_mpg[i - 1];
  }
  for (i in 2:K_wt) {
    means_X_wt[i - 1] = mean(X_wt[, i]);
    Xc_wt[, i - 1] = X_wt[, i] - means_X_wt[i - 1];
  }
  for (i in 2:K_sigma_wt) {
    means_X_sigma_wt[i - 1] = mean(X_sigma_wt[, i]);
    Xc_sigma_wt[, i - 1] = X_sigma_wt[, i] - means_X_sigma_wt[i - 1];
  }
}
parameters {
  vector[Kc_mpg] b_mpg;  // population-level effects
  real Intercept_mpg;  // temporary intercept for centered predictors
  vector[Kc_sigma_mpg] b_sigma_mpg;  // population-level effects
  real Intercept_sigma_mpg;  // temporary intercept for centered predictors
  vector[Kc_wt] b_wt;  // population-level effects
  real Intercept_wt;  // temporary intercept for centered predictors
  vector[Kc_sigma_wt] b_sigma_wt;  // population-level effects
  real Intercept_sigma_wt;  // temporary intercept for centered predictors
}
transformed parameters {
}
model {
  // initialize linear predictor term
  vector[N_mpg] mu_mpg = Intercept_mpg + Xc_mpg * b_mpg;
  // initialize linear predictor term
  vector[N_mpg] sigma_mpg = Intercept_sigma_mpg + Xc_sigma_mpg * b_sigma_mpg;
  // initialize linear predictor term
  vector[N_wt] mu_wt = Intercept_wt + Xc_wt * b_wt;
  // initialize linear predictor term
  vector[N_wt] sigma_wt = Intercept_sigma_wt + Xc_sigma_wt * b_sigma_wt;
  for (n in 1:N_mpg) {
    // apply the inverse link function
    sigma_mpg[n] = exp(sigma_mpg[n]);
  }
  for (n in 1:N_wt) {
    // apply the inverse link function
    sigma_wt[n] = exp(sigma_wt[n]);
  }
  // priors including all constants
  target += student_t_lpdf(Intercept_mpg | 3, 19, 10);
  target += student_t_lpdf(Intercept_sigma_mpg | 3, 0, 10);
  target += student_t_lpdf(Intercept_wt | 3, 3, 10);
  target += student_t_lpdf(Intercept_sigma_wt | 3, 0, 10);
  // likelihood including all constants
  if (!prior_only) {
    target += normal_lpdf(Y_mpg | mu_mpg, sigma_mpg);
    target += normal_lpdf(Y_wt | mu_wt, sigma_wt);
  }
}
generated quantities {
  // actual population-level intercept
  real b_mpg_Intercept = Intercept_mpg - dot_product(means_X_mpg, b_mpg);
  // actual population-level intercept
  real b_sigma_mpg_Intercept = Intercept_sigma_mpg - dot_product(means_X_sigma_mpg, b_sigma_mpg);
  // actual population-level intercept
  real b_wt_Intercept = Intercept_wt - dot_product(means_X_wt, b_wt);
  // actual population-level intercept
  real b_sigma_wt_Intercept = Intercept_sigma_wt - dot_product(means_X_sigma_wt, b_sigma_wt);
}