I notice that this combines both a sampling statement “~”, which drops constant terms in the log likelihood, and “target +=” which doesn’t, and I’m not sure if mixing the two is an issue or not. Is this a red flag, or should I not worry about it?
Except that the Stan language manual makes clear that’s almost but not quite true. That’s why I was asking about it. I wanted to know if the subtle difference between the two would make a material difference.
(Also, given how V_T is defined, that’s not defining a Gaussian distribution for y[i] twice, but that’s a side note.)
They are equivalent for all of the algorithms currently supported in Stan. Any difference is in the normalizing constants which is superficial.
If you factor the quadratic then one of the three terms you get is the unnormalized version normal_lpdf(y[i] | mu_M[i], uy[i]) so with both lines you are adding that distribution twice, effectively halving the standard deviations.
Yeah, I see what you mean. Not sure why they’re doing that, but that’s probably outside the purview of the Stan forums.
(FWIW, the paper related to those Stan files (and others) is at this DOI: 10.1002/aic.15781, if you’re interested. I’m still working on making sense of it and its associated codes.)
If we use target += normal_lpdf(y[i] | mu_M[i], uy[i]) then y[i] has to be an observed data, right, I mean y[i] cannot be a missing data or any parameters?