Hi,

I’m fairly new to stan, R and Bayesian, so sorry if my mistake is very rudimentary.

I’m ‘attempting’ to estimate a hierarchical model in rstan, but I’m receiving the following error messages when attempting to executing the sampling:

'[1] "Error in sampler$call_sampler(args_list[[i]]) : ’

and,

'[2] “Exception: []: accessing element out of range. index 6 out of range; expecting index to be between 1 and 0; index position = 1alpha (in ‘model126678353ad_Varying_Slope_Model_NoCov’ at line 31)”

Here is the model:

```
data {
int N; //number of participants
real behaviour[N]; //outcome
int respondent[N]; //vector of respondent IDs
real prevalence[N]; //predictor
int K; //number of respondents
}
```

```
parameters {
real alpha[K]; //respondent intercepts
real beta_prevalence[K]; //respondent slopes
real sigma[K]; //respondent variance
real alpha_top; //pooled intercept
real<lower=0> alpha_sigma; //pooled intercept variance
real beta_p_top; //pooled slope
real beta_p_sigma; //pooled slope variance
}
```

```
model {
for(i in 1:N) {
int aRespondent;
aRespondent = respondent[i];
behaviour[i] ~ normal(alpha[aRespondent] + beta_prevalence[aRespondent]*prevalence[i], sigma[aRespondent]);
}
alpha ~ normal(alpha_top, alpha_sigma); //priors
beta_prevalence ~ normal(beta_p_top, beta_p_sigma); //priors
sigma ~ normal(0,2); //priors
alpha_top ~ normal(0,2); //hyperpriors
beta_p_top ~ normal(0,2); //hyperpriors
alpha_sigma ~ normal(0,2); //hyperpriors
beta_p_sigma ~ normal(0,2); //hyperpriors
}
```

```
generated quantities {
real alpha_overall;
real beta_p_overall;
alpha_overall = normal_rng(alpha_top, alpha_sigma);
beta_p_overall = normal_rng(beta_p_top, beta_p_sigma);
```

Does anyone know if i’ve made a silly coding error?