Repository navigation
Report no LOOIC weights for models fit to different numbers of observations in compare_performance() - #985
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Matching row counts do not ensure pointwise observations are aligned across models.
1 open issue
1 file not reviewed
man/compare_performance.Rd: Generated file
What changed in this PR
This pull request prevents invalid LOOIC stacking weights when models have different pointwise observation counts.
Changes:
- Returns
NAweights and warns when observation counts differ. - Preserves weights for matching counts.
- Adds regression tests, documentation, NEWS, and a version bump.
| File | Summary |
|---|---|
tests/testthat/test-compare_performance.R |
Adds regression coverage. |
R/compare_performance.R |
Validates pointwise row counts before stacking. |
NEWS.md |
Documents the bug fix. |
man/compare_performance.Rd |
Documents LOOIC weight behavior. |
DESCRIPTION |
Increments the package development version. |
Review effort: Lite
…numbers of observations
jmgirard
force-pushed
the
loo-unequal-observations
branch
from
October 18, 2026 14:27
3cdc56a to
0302562
Compare
Merged
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.

compare_performance()computes LOOIC stacking weights from the pointwiseelpd_loovalues of each model withcbind(). When the models were fit to different numbers of observations,cbind()recycled the shorter column, andloo::stacking_weights()returned wrong weights. For 32 rows against 150 rows base R warned "number of rows of result is not a multiple of vector length". For 32 rows against 64 rows there was no warning at all.An example is
brms_1(32 observations) withbrms_4(150 observations) frominsight::download_model(). On main the LOOIC weights are 0.000 and 1.000.What changes
compare_performance()givesNAfor all LOOIC weights and, withverbose = TRUE, warns with the counts. Models with the same number of rows keep their weights.NAin this case.Tests
brms_1withbrms_4, also withrank = TRUE, with a copy ofbrms_1as a third model, and withverbose = FALSE.model_performance()results with 32 and 64 rows, wherecbind()recycled without a warning, and with a third model that has no LOOIC.brms_1with a copy of itself still gets the weights 0.5 and 0.5, as on main.The new tests fail on main and pass with this change.