Repository navigation
Use subsampling estimates for pseudo-BMA weights in loo_model_weights() - #414
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #414 +/- ##
==========================================
+ Coverage 92.49% 92.54% +0.04%
==========================================
Files 31 31
Lines 3143 3164 +21
==========================================
+ Hits 2907 2928 +21
Misses 236 236 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 8a7462a is merged into master:
|
jgabry
requested changes
Oct 21, 2026
jgabry
left a comment
Member
There was a problem hiding this comment.
Looks good, just a few small suggestions
Member
Author
|
Applied / added all your suggestions |
jgabry
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR was assisted by Claude
Summary
#409 makes
loo_model_weights()reject objects fromloo_subsample(), because their pointwise values cover only the subsampled observations. Pseudo-BMA without the Bayesian bootstrap does not need pointwise values: the weights are proportional toexp(elpd_loo)of each model, andloo_subsample()estimateselpd_loofor all observations. With this PR,loo_model_weights(x, method = "pseudobma", BB = FALSE)accepts objects fromloo_subsample()and uses their estimates ofelpd_loo. The subsamples and their sizes can differ between the models, and a list can mix subsampled and full objects.Stacking and pseudo-BMA+ (
BB = TRUE, the default) still reject subsampled objects. Both need the pointwise values of the same observations for all models. The error message now names the supported combination: "loo_model_weights() supports objects from loo_subsample() only with method = "pseudobma" and BB = FALSE, because they have pointwise values only for the subsampled observations. Use loo() for all observations."Change
validate_psis_loo_list()has a new argumentallow_subsampling, whichloo_model_weights()sets formethod = "pseudobma"andBB = FALSE. The check that all models have the same number of observations useslength(x$loo_subsampling$elpd_loo_approx)for a subsampled object, becausenobs()returns the size of the subsample.pseudobma_weights_from_elpd()computes the weights from a vector ofelpd_loovalues.pseudobma_weights(BB = FALSE)uses it too, so its results do not change.xdescribes which methods accept objects fromloo_subsample().Tests
The test for subsampled objects from #409 now checks:
method = "pseudobma"withBB = TRUE, reject two subsampled objects and a mix of a subsampled and a full object;method = "pseudobma",BB = FALSEgivesexp(elpd_loo)-proportional weights from the subsampling estimates, for two subsampled objects with different subsamples of 50 and 80 observations, and for a mix of a full and a subsampled object;With the R code of #409, this test fails.
devtools::test()withNOT_CRAN=truepasses all 1279 tests and gives no warnings (R 4.6.1, testthat 3.3.2, Linux x86_64).