I’m receiving an error message for the model below, that I haven’t encountered before. The model is as follows:

```
model = "data {
int j; //number of participants
int i; //number of trials per participant
int<lower=0,upper=1> response1[j,i]; //choices per trial per participant first phase, 1=left, 0=right
vector[i] omega_left[j]; //dots in the left circle
vector[i] omega_right[j]; //dots in the right circle
vector<lower=0,upper=1>[i] confidence1[j]; //first confidence rating
}
parameters {
real<lower=0> mu_k; //mean of k
real<lower=0, upper=10> sd_k; //sd of k
real<lower=0> conf_error[j];
real<lower=0> k[j];
}
transformed parameters {
vector[i] x_left1[j];
vector[i] x_right1[j];
vector[i] mu_posterior1[j];
vector[i] c1[j];
for (p in 1:j) {
for (t in 1:i) {
mu_posterior1[p,t] = 1 - exp(normal_lcdf(0 | (omega_left[p,t]-omega_right[p,t]), 2));
c1[p,t] = 2*fabs(mu_posterior1[p,t] - 0.5);
}
}
}
model {
// hyperparameters
mu_k ~ normal(0,10);
for (p in 1:j) {
// priors
k[p] ~ normal(mu_k, sd_k);
conf_error[p] ~ cauchy(0,0.5);
for (t in 1:i) {
x_left1[p,t] ~ normal(k[p]*omega_left[p,t], 1);
x_right1[p,t] ~ normal(k[p]*omega_right[p,t], 1);
response1[p,t] ~ bernoulli_logit(x_left1[p,t]-x_right1[p,t]);
confidence1[p,t] ~ normal(c1[p,t], conf_error[p]);
}
}
}"
```

The error I’m getting is the following:

Rejecting initial value:

Error evaluating the log probability at the initial value.

Exception: normal_lpdf: Random variable is nan, but must not be nan! (in ‘model17221aa21d3_bc3f72929b6c0ef57fc8ebefd5ade92d’ at line 105)

It is referring to this line (and I suppose the same would hold for the line under it):

```
x_left1[p,t] ~ normal(k[p]*omega_left[p,t], 1);
```

I have tried several solutions posed online, which mostly involved changing the initial values, but none of these have helped. I have also tried changing this line to:

```
x_left1[p,t] ~ normal(1,1)
```

, which doesn’t work either, meaning there must be some syntax error somewhere that I’m missing.

Again, I have used this sampling statement before and it never gave me any issues. It would be great if anybody could give me any suggestions as to what else to try.

Thanks a lot!