Hi all,

I’m receiving the following error in my code for a simple hierarchical model.

Chain 1: Rejecting initial value:

Chain 1: Error evaluating the log probability at the initial value.

Chain 1: Exception: normal_lpdf: Location parameter is nan, but must be finite! (in ‘model1b61b3dabc9_d0ce4f9540376bb49b8354006ddbdb68’ at line 28)

I did look at the topics and googled the message, but didn’t see a response that helped with this problem. Here is the code.

modelString = "

data {

int<lower=1> n; // number of students

int<lower=1> G; // number of schools

int schid[n]; // school indices

vector[n] ASRREA01; // reading outcome variable

vector[n] ASBG04;

vector[n] ACBG03A;

}

parameters {

vector[G] gamma00;

vector[G] gamma01;

vector[G] alpha;

vector[G] beta1;

vector[n] mu_beta1;

vector[G] mu_alpha;

vector<lower=0>[n] sigma_read;

vector<lower=0>[n] sigma_alpha;

vector<lower=0>[G] sigma_beta1;

}

model {

vector[n] mu;

for (i in 1:n) {

ASRREA01[i] ~ normal(mu[i], sigma_read);

mu[i] = alpha[schid[i]] + beta1[schid[i]]*ASBG04[i];

}

for (g in 1: G) {

alpha[g] ~ normal(mu_alpha, sigma_alpha);

// mu_alpha[g] = gamma00 + gamma01*ACBG03A[g];

beta1[g] ~ normal(mu_beta1, sigma_beta1);

}

// Priors

gamma00 ~ normal(300,100);

gamma01 ~ normal(0, 5);

mu_beta1 ~ normal(0, 5);

mu_alpha ~ normal(100,10);

sigma_read ~ cauchy(1,5);

sigma_alpha ~ cauchy(1,5);

sigma_beta1 ~ cauchy(1,5);

}

"

Notice that when take out the comment in the line that reads

mu_alpha[g] = gamma00 + gamma01*ACBG03A[g];

I get the following error message

## error in ‘model1b61ba56473_d6caa3c42c5f7321f5f780652f54c304’ at line 34, column 5

```
32: for (g in 1: G) {
33: alpha[g] ~ normal(mu_alpha, sigma_alpha);
34: mu_alpha[g] = gamma00 + gamma01*ACBG03A[g];
^
35: beta1[g] ~ normal(mu_beta1, sigma_beta1);
```

PARSER EXPECTED: “}”

Error in stanc(file = file, model_code = model_code, model_name = model_name, :

failed to parse Stan model ‘d6caa3c42c5f7321f5f780652f54c304’ due to the above error.

Thanks in advance,

David