I have been trying to get an lpdf model statement to give me a vector instead of a real that has already summed the vector, and I realized that this was proposed but possibly not realized (https://github.com/stan-dev/stan/wiki/Stan-3-Density-Notation-and-Increments). I was wondering if there was any insight on how I could get a vector output.
I was considering a user-defined probability function, but I doubted if I would get any speed improvement out of that.
The ony way to get a vector out is to use a loop. Building this in is still on the to-do list.
Thanks for confirming. And thanks for all the improvements to Stan!
@Bob_Carpenter Thanks again for the reply here earlier. Is there any update on this? I was just running into the same problem - I would need a
normal_lpdf that returns a vector if I give it a vector (similar like in R
dnorm would do).
lpdf functions are engineered around returning the sum for vectorised inputs, so this is not likely to be a default supported signature any time soon. Additionally, any implementation would likely to be little more than looping over the inputs so there wouldn’t be any benefits from vectorisation.
You could implement this yourself as a user-defined function in your Stan model, alternatively something that could do this for you in the future would the
rowwise/colwise framework in discussion over here: Rowwise/Colwise Framework by andrjohns · Pull Request #35 · stan-dev/design-docs · GitHub