Rstan - extend accumulators?


rstan has so many hidden features… I just learned on the mailinglist that means are always recorded on all parameters generated, even the ones which one excludes from recording.

For loo and waic calculations we need the pointwise log-lik in order to get the pointwise mean and variance of that, right? If so, then expanding the accumulators to second moments would be very useful as one could then omit the log_lik posterior.

This could be handy for models with many data points.

@ Aki: Makes sense?

If so… do we have a feature request already or should I write one?


The mean / variance really should be done in Stan. There was a thread on this a few days ago.

That would go into a writer, right? Or are you thinking of breaking out the accumulators?

Awesome. Make sense to put that into Stan directly.

Sorry, I did not see that discussion; glad its already addressed.


As far as I understand, neither:

All caught up now, thanks for the link. K

Variance accumulator would probably be useful for various things, but not enough for PSIS-LOO. PSIS-LOO requires the distribution of the importance weights - which are proportional to exp(-log_lik) - to get Pareto k for diagnostics and for smoothing the weights. Plain IS-LOO or WAIC is not as reliable as PSIS-LOO.