Using loo with cmdstanr

I want to use functionality from the loo package with output from cmdstanr. I’ve got log_lik in the generated quantities block of the model but as the output from cmdstanr sampling is not a stanfit object I can’t use extract_log_lik or similar functions it seems. Is there a straightforward way of using the loo functionality with cmdstanr output or any guidance or examples anywhere?

Yeah it should just be

# assuming 'fit' is your fitted model object and you used the name 'log_lik' in generated quantities  

Does that work for you?


Ah yes it does! That was simpler than I thought. Thanks!


I added an issue for cmdstanr
as it would be quite easy to add support for loo(fit) that would also take into account r_eff part missing in the above answer.