Rework PLPD and LPD approximation for loo_subsample()
#192
+878
−609
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements new functions that support the PLPD approximation method alongside the existing LPD method for PSIS-LOO-CV sub-sampling. Also shifts around some of the helper functions in
helper_loo.py
to group similar functions together.The
_compute_loo_approximation()
function is the biggest change here, facilitating the PLPD and LPD approximations with user provided log-likelihood functions.Major Changes
New
_compute_loo_approximation()
function:lpd
andplpd
methods through a single, clean interface and allows a custom log-likelihood function for the LPD approximation as wellWhen using custom log-likelihood functions with
loo_subsample()
, the function must take the observed data and theDataTree
object as args. For both approximations, I think this is all the user would need to construct a log-likelihood function.The
DataTree
should also contain aconstant_data
group with any extra data like covariates needed to construct the log-likelihood function. The internal helper function will specifically look for this group, and only this group, if it is used to grab data necessary for creating the log-likelihood function (like in the Wells example below):I validated this new rework against the
loo
package using the Wells dataset example from https://mc-stan.org/loo/articles/loo2-large-data.html. You can download the Wells data from theloo
package:We get output that is nearly identical to the R output for the PLPD approximation (LPD and
update_subsample()
are also nearly identical as well):arviz-stats:
loo package:
Resolves #178
📚 Documentation preview 📚: https://arviz-stats--192.org.readthedocs.build/en/192/