Extract log-likelihood function from rstanarm model

I now quickly checked my old code. I extracted the log likelihood function from within the rstanarm package for the very specific models at hand. Hence, it worked for the project - but is not good for production/reuse.

I think it should be better to try to do this using the rstanarm public API. I looked it up and it seems like the log_likelihood function can be accessed using newdata. So you would just supply a row of your data to newdata to get the log_lik values for the subset of data, although. Im not sure if this work for loo_subsampling, I do not remember.

It is also possible to get the log_likelihood function directly (what I can tell) using rstanarm:::ll_fun(object). This mean that you would sidestep the rstanarm API so you would need to check that it works as expected (maybe compare with log_lik for a small subsample). Here is the code (71-89, 105-111, and 169-184):

Could you try and see if this would work?

I have also opened an issue to try to get this into rstanarm here:

/Måns