# Posterior predictive checks of a Multilevel regression model

[Please include Stan program and accompanying data if possible]
Dear all,
I’m very new to STAN and I’m enjoying it !
I was able to generate a good model that converged then I got stuck when I moved to the validation/ evaluation part.
My model is a Multilevel logistic

``````code1 <-"
data{
int<lower=1> n;
int<lower=1> N_JSLA;
int H6[n];
int JSLA[n];
int I22[n];
int I25[n];
int D5[n];
int I24[n];
int A10[n];
int A9[n];
int B3[n];
}
parameters{
vector[N_JSLA] a_JSLA_raw;
real a;
real<lower=0> sigma_JSLA;
real b5;
real bd;
real b2;
real b4;
real ba;
real b9;
real b3;
}
transformed parameters{
vector[N_JSLA] a_JSLA;
a_JSLA = 0 + a_JSLA_raw*sigma_JSLA;//implies a_JSLA ~ normal(0, sigma_JSLA)
}

model{
vector[n] p;
sigma_JSLA ~ cauchy( 0 , 1 );
a ~ normal( 0 , 1 );
a_JSLA_raw ~ normal( 0 , 1 );
b2 ~ normal( 0 , 1 );
b5 ~ normal( 0 , 1 );
bd~ normal( 0 , 1 );
b4~ normal( 0 , 1 );
ba~ normal( 0 , 1 );
b9~ normal( 0 , 1 );
b3~ normal( 0 , 1 );

for ( i in 1:n ) {
p[i] = a + a_JSLA[JSLA[i]]+b2*I22[i]+b5*I25[i]+bd*D5[i]+b4*I24[i]+ba*A10[i]+b9*A9[i]+b3*B3[i];

}
H6 ~ binomial_logit( 1 , p );
}
generated quantities{
vector[n] p;
vector[n] log_lik;

for ( i in 1:n ) {
p[i] = a + a_JSLA[JSLA[i]]+b2*I22[i]+b5*I25[i]+bd*D5[i]+b4*I24[i]+ba*A10[i]+b9*A9[i]+b3*B3[i];
log_lik[i] = binomial_logit_lpmf(H6[i]|1,p[i]);
}

}

"
``````

After running the model

``````options(mc.cores = parallel::detectCores())
m1.1 <- stan(model_code = code1, data=d, iter=3000, chains=4,cores=4, thin=1,
warmup=1000, control = list(adapt_delta = 0.9, stepsize=1))
``````

and looking at the traceplots, I extracted samples from the post. distribution
`postm1.1<-extract(m1.1)`

Then I got stuck ! Any tutorial or steps that I could follow are welcome.
I will be happy to give further details about my model if needed.
Thank you

general suggestions:

cheers,
Mitzi