Loo 2.0 with very large stanfit crashes R

This whole “calculate log_lik in generated quantities thing” is for situations where RAM is not an issue. The foo.function method is the more general way of doing it, which is used by rstanarm and brms.

You can write a function that takes data_i, creates a new empty stanfit object that is instantiated with only the i-th observation worth of data, call the constrain_parameters function for each of the S draws, and return that vector.