I want a variable inside a JAGS model to be assigned a value with probability p[i] and another value with probability 1-p[i]. p[i] is a variable in the model.
I have tried the following but I am not sure it is appropriate. I am afraid a single value (0 or 1) will be attributed to subject i and this value will always stay the same: for a given subject i, the values in the vector a[i] will always be equal to 20 or to 30. What I would like to get instead is a vector containing 20s and 30s, with the probability of 20 being equal to p[i].
for (i in 1:n) {
m[i] ~ dbin(p[i],1)
a[i] <- ifelse(m[i]==1, 20, 30)
}
Aucun commentaire:
Enregistrer un commentaire