# Error specifying multivariate normal prior

Hi,

I’m trying to code a model where group-level parameters are correlated and hence drawn from a multivariate normal. I am Below is my model:

``````data{
int<lower=1> N; // rows of observations
int<lower=0> sdl[N]; // observed response
int<lower=1> K; //no.of predictors
int<lower=1> J; //no.of groups
int<lower=1> L; // num group-level predictors
matrix[N,K] X; // population-level predictor
int<lower=1, upper=J> jj[N]; // number of groups
}

parameters{
corr_matrix[K] Omega; //  correlation matrix
vector<lower=0>[K] tau; //  scale
vector[K] beta[J]; // indiv coeffs per group
real<lower=0> phi;  // shape parameter
}

model{
vector[N] x_beta_jj; // mean expectation
matrix[K,K] Sigma_beta;
vector[2] mu_beta;
tau ~ cauchy(0,5);
Omega ~ lkj_corr(2.0); // prior covariance

mu_a ~ normal(0, 10);
mu_b ~ normal(0, 10);

// random effect priors
for (j in 1:J)
mu_beta[1] = mu_a;
mu_beta[2] = mu_b;
beta ~ multi_normal(mu_beta, Sigma_beta);

phi ~ gamma(0.01, 0.01);

// Likelihood
for (n in 1:N)
x_beta_jj[n] = (X[n]*beta[jj[n]]); //log location
sdl ~ neg_binomial_2_log(x_beta_jj, phi);
}
``````

With this model, I get the following error:

``````SYNTAX ERROR, MESSAGE(S) FROM PARSER:

variable "mu_a" does not exist.
``````

I tried to tweak the multivariate specification based on the Stan User Manual, but was unsuccessful. Any help will be much appreciated!

Thanks,
Meghna

`mu_a` and `mu_b` have to be declared in the `parameters` block. Also, there are some mistakes with missing { and this centered approach probably will not work well anyway. There is stuff in the manual about non-centered reparameterizations but I would suggest that you start by estimating your model with `rstanarm::stan_glmer` or `brms::brm` so that you know what the right answer is before trying to recreate it yourself.