// generated with brms 2.16.0
functions {
  /* multinomial-logit log-PMF
   * Args: 
   *   y: array of integer response values
   *   mu: vector of category logit probabilities
   * Returns:  
   *   a scalar to be added to the log posterior 
   */ 
   real multinomial_logit2_lpmf(int[] y, vector mu) {
     return multinomial_lpmf(y | softmax(mu));
   }
}
data {
  int<lower=1> N;  // total number of observations
  int<lower=2> ncat;  // number of categories
  int Y[N, ncat];  // response array
  int trials[N];  // number of trials
  int prior_only;  // should the likelihood be ignored?
}
transformed data {
}
parameters {
  real Intercept_mub;  // temporary intercept for centered predictors
  real Intercept_muc;  // temporary intercept for centered predictors
}
transformed parameters {
}
model {
  // likelihood including constants
  if (!prior_only) {
    // initialize linear predictor term
    vector[N] mub = Intercept_mub + rep_vector(0.0, N);
    // initialize linear predictor term
    vector[N] muc = Intercept_muc + rep_vector(0.0, N);
    // linear predictor matrix
    vector[ncat] mu[N];
    for (n in 1:N) {
      mu[n] = transpose([0, mub[n], muc[n]]);
    }
    for (n in 1:N) {
      target += multinomial_logit2_lpmf(Y[n] | mu[n]);
    }
  }
  // priors including constants
  target += student_t_lpdf(Intercept_mub | 3, 0, 2.5);
  target += student_t_lpdf(Intercept_muc | 3, 0, 2.5);
}
generated quantities {
  // actual population-level intercept
  real b_mub_Intercept = Intercept_mub;
  // actual population-level intercept
  real b_muc_Intercept = Intercept_muc;
}

# Adaptation terminated
# Step size = 0.697714
# Diagonal elements of inverse mass matrix:
# 0.000578946, 0.000429066

# Adaptation terminated
# Step size = 0.534544
# Diagonal elements of inverse mass matrix:
# 0.000698019, 0.000443327