3 Level Multilevel Model Specification

Nice catch! Thank you for your response.

I made what I think is the correct update to the Stan model:

real a[P]; // page level random effects
vector[P] alpha; // page level random effects

which are assigned in these components:

// page level
for (i in 1:P){
       alpha[i] <- a[page[i]];
}
a ~ normal(a_mu, sigma_a);

If I’m understanding the syntax correctly, alpha and a are each P parameters and the loop should estimate all P of them. Let me know if that’s wrong.

However, my model is still failing to initialize. Curiously, the error message now indicates that “Random variable[1] is nan, but must not be nan!”, whereas in the last message, it was Random variable[5] - so it’s possible that fixed one issue.

Is there a way to map the Random variable[index] to the associated parameter in the model? That might help tip me off to where the issue is arising…