> How can y[n] be sampled from a Bernoulli if it is >1?
You're right, if you follow the notation of manual for Hurdle
distribution, it should be:
(y[n] == 0) ~ bernoulli(theta);
if (y[n] > 0)
y[n] ~ poisson(lambda) T[1,];
Example:
stanm2 <- stan_model(model_code="
data {
int y[3];
}
parameters {
real<lower=0, upper=1> theta;
real<lower=0> lambda;
}
model {
for (n in 1:3) {
(y[n] == 0) ~ bernoulli(theta);
if (y[n] > 0)
y[n] ~ poisson(lambda) T[1,];
}
}")
fit1 <- sampling(stanm2, chains = 2, iter = 1e4, data = list(y = c(1,2,0)))