Right function for calculating brms model's lpd for new data


What’s the right function to use in order to calculate a brms model’s Log Predictive Density for an actual new dataset? I’m looking for something that will yield a single scalar like elpd_loo, except that now it’s a real lpd rather than expected, and now it’s computed from actual new data rather than just for left-out observations. As you probably guessed, I need the returned result to be straightforwardly comparable to PSIS-approximated elpd_loos calculated by loo().

log_lik(... , new_data = your_new_data)

1 Like

Great! I was confused by the fact that it’s called “likelihood”, which could be paranoidly interpreted to mean that the calculation is based only on the likelihood, rather than the posterior. Thanks for clearing this up!

It is the log likelihood (just the likelihood not the log posterior), evaluated at the parameter values that are draws from the posterior. So it is “based only on the likelihood”, but it is evaluated for a fitted model that is not itself “based only on the likelihood”.

1 Like