Difference between y ~ poisson_log(...) and y[i] ~ poisson_log(...) in for-loop?

What’s the difference between specifying y ~ poisson_log(…) vs specifying this as:

for(i in 1:N) {
    y[i] ~ poisson_log(log_rate);
}

as e.g. in:

1 Like

The two approaches are equivalent, but the loop is less efficient. See this section of the manual for more background: 24.8 Vectorization | Stan User’s Guide

2 Likes