Vectorizing bernoulli_logit_lpmf()

I’ve been looking into vectorizing the code for a Stan model and stumbled upon the issue of not being able to vectorizing bernoulli_logit_lpmf()

the current (working) code says

for (i in 1:N) {
log_lik[i] = bernoulli_logit_lpmf( Outcome[i] | mu[i] )
}

I’d like to turn it into

log_lik = bernoulli_logit_lpmf( Outcome | mu)

but this does not seem to work. Is there something obvious I’m missing, or is the function not vectorizable?

Thanks.
Riccardo

If you are trying to obtain the log likelihood for each observation, then the loop version is the only way to do it. The _lp{m,d}f functions return a scalar when passed containers, representing the log likelihood summed over conditionally independent observations.

ok. thanks! this makes sense.