Hi all,
I’ve just started using Stan some days ago.
Reading the Stan reference 2.17.1, I see that one need to take care of order of statements, not like in BUGS.
https://github.com/stan-dev/stan/releases/download/v2.17.1/stan-reference-2.17.1.pdf
I’ve a question of the order of statements in model block.
On the page 144, the model block of 1PL (Rasch) Model is written as
model {
alpha ~ normal(0, 1); // informative true prior
beta ~ normal(0, 1); // informative true prior
delta ~ normal(0.75, 1); // informative true prior
for (n in 1:N)
y[n] ~ bernoulli_logit(alpha[jj[n]] - beta[kk[n]] + delta);
}
Since y[n] need to use the values of alpha, beta, delta, we need to declare them first.
But on the page 145, for the Multilevel 2PL Model, I see that while beta and gamma need the values of sigma_beta and sigma_gamma, beta and gamma are “written” before sigma_beta and sigma_gamma:
model {
alpha ~ normal(0, 1);
beta ~ normal(0, sigma_beta);
gamma ~ lognormal(0, sigma_gamma);
mu_beta ~ cauchy(0, 5);
sigma_beta ~ cauchy(0, 5);
sigma_gamma ~ cauchy(0, 5);
for (n in 1:N)
y[n] ~ bernoulli_logit(gamma[kk[n]]* (alpha[jj[n]] - (beta[kk[n]] + mu_beta)));
}
Could you please explain to me why, and can we assign values for sigma_beta and sigma_gamma before feeding them to alpha and beta, e.g:
model {
alpha ~ normal(0, 1);
mu_beta ~ cauchy(0, 5);
sigma_beta ~ cauchy(0, 5);
sigma_gamma ~ cauchy(0, 5);beta ~ normal(0, sigma_beta);
gamma ~ lognormal(0, sigma_gamma);for (n in 1:N)
y[n] ~ bernoulli_logit(gamma[kk[n]]* (alpha[jj[n]] - (beta[kk[n]] + mu_beta)));
}
Thank you very much in advance!