# Assessing speed of multilevel model

Hi, I am new to Stan and exploring different parameterizations of a model.

I was wondering if I could get feedback about the efficiency of this parametrization? It takes a bit over an hour to run with only 7000 observations. On simulated data it has finished in 10 minutes with the same amount of observations.

``````data {
int<lower = 1> nB;
int <lower = 1> nC;
int <lower = 1> nS;
int<lower = 1> size_c[nB];
int<lower = 1> size_t[nB];
int<lower = 1, upper = nC> cid[nB];
int<lower = 1, upper = nS> sid[nC];
vector[nB] d;
int y_t[nB];
int y_c[nB];
}
parameters {
real <lower=0> sigma_u0l;
vector[nS] mu_0l;
real <lower=0> sigma_u0kl;
vector[nC] mu_0kl;
real beta_0;
real beta_d;
}
transformed parameters {
vector[nS] beta_0l;
vector[nC] beta_0kl;
beta_0l = beta_0+mu_0l;
beta_0kl = mu_0kl+beta_0l[sid];
}
model {
vector[nB] p_c;
vector[nB] p_t;
sigma_u0l ~ normal(.1,.1);
sigma_u0kl ~ normal(.1,.5);
beta_0 ~ normal(0,.1);
beta_d ~ normal(1,2);
mu_0kl ~ normal(0,sigma_u0kl);
mu_0l ~ normal(0,sigma_u0l);
p_c = beta_0kl[cid];
p_t = beta_0kl[cid]+d*beta_d;
y_c ~  binomial_logit(size_c,p_c);
y_t ~  binomial_logit(size_t,p_t);
}
``````

Thank you!

Welcome to the forum!

Can you show the estimated values? Your priors are tight, some are unusual like normal(0.1, 0.1)
for a standard deviation. It might be that your estimates are off from your priors, thus Stan needs longer
to run. It’s hard to say more without further information.

1 Like