Error message with binomial_logit: "y is 4, but must be less than or equal to 1"

Hi All,

I am having an issue with the following model block:

model {

for(i in 1:n) { y[i]

~ binomial_logit(t[i],b0 + b[1]*Age[i] + b[2]*OMElow[i] + b[3]*Loud[i] + b[4]*Noiseincoherent[i]);};

for (num in 1:j) {b[num] ~ normal(0,1/16);};

b0 ~ normal(0.0, 1.0/25);}

When I input the success numbers y[i] from t[i] trials I have the error message saying that “y[i_0__] is 4, but must be less than or equal to 1”. What am I missing to pass correctly the number of sucesses per observation?

Thanks a lot.


You are modelling yas a binomial outcome, which means that it should only take the values of 0 or 1. The error is telling you that it encountered a 4 in the y vector. Presumably y is data? If so, you need to check that the values are all 0 or 1.

Oops! My bad, I just realized I was thinking of bernoulli_logit.

With binomial_logit you have everything right in terms of the model, and the ys can be >1, BUT t[i] must be greater or equal to y[i], so you should check the data you’re passing in to ensure this is the case.