Here is what may sound like a stupid question (even to me), but I am trying to double check my understanding.
If I have defined a variable called log_lik for the purposes of LOO computation, in the generated quantities block, my expectation was that if I summed up the values of log_lik over all the observations, I would get the same value as lp__, which is returned directly from Stan.
As a quick check, I just printed out the stanfit object, getting means, SE, percentiles etc. for all the parameters, including each observation-specific value of log_lik and lp__, and compared the sum of the means of the log_lik values to the mean lp__ value. I expected that they would be very close.
In some cases, that was true. But in others, it was not true. My bottom-line question is: should I use that as an indicator that I have coded something wrong (probably in the generated quantities block, though I essentially just copied the calculations leading to the “target += …” statement)? Or is there another reason I could be seeing differences in the quick check that I just described?
Thanks in advance for assistance on this problem,