Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #410 +/- ##
==========================================
+ Coverage 92.48% 92.50% +0.02%
==========================================
Files 31 31
Lines 3139 3204 +65
==========================================
+ Hits 2903 2964 +61
- Misses 236 240 +4 ☔ 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 8db33ac is merged into master:
|
This branch has not been deployed
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.
Fixes #274.
This PR was Claude assisted
Summary
loo_moment_match()callslog_prob_upars()andlog_lik_i_upars()on transformed draws, which can be more extreme than the posterior draws, and the model code can throw an error for them. In #274,neg_binomial_2_rngin thegenerated quantitiesblock overflows, because cmdstanr'slog_lik_i_upars()runs the whole block to getlog_lik.The split step at the end called
log_lik_i_upars()withouttry(), so an error there stoppedloo_moment_match(). Withcores > 1and two or more observations,parallel::mclapply()returned the error as a string, and the result loop then failed with "$ operator is invalid for atomic vectors".In the transformation loop,
try()printed the error, and the loop stopped for that observation. The user got no warning that moment matching had stopped early.Change
split = FALSE. The accuracy warning thatsplit = FALSEgives for a large Pareto k of the self-normalized weights now also covers these observations, with a text that refers to the failed split.log_lik_i(), that observation keeps its PSIS results. Atry-errorfrom amclapply()worker gets the same treatment.try()withsilent = TRUE. One warning lists the observations for which moment matching stopped early or failed, and shows the first error message.cmdstanr cannot avoid the error: its
log_lik_i_upars()needs thegenerated quantitiesblock to computelog_lik, and the block also runs the*_rngcalls. Users can move the*_rngcode to a standalone generated quantities run.Tests
Four new tests in
tests/testthat/test_loo_moment_matching.Ruse the existing test model, with alog_lik_i_upars()orlog_lik_i()that fails in chosen calls:split = FALSE.log_lik_i()fails for observation 1, withk_threshold = 0so that 30 observations go through moment matching, once withcores = 1and once withcores = 2. Observation 1 keeps its PSIS results, and the other observations get the same results as without the error.With the master
R/loo_moment_matching.R, all four tests fail: three stop with an error, and one fails an expectation. With this PR,devtools::test()withNOT_CRAN=truepasses all 1280 tests and gives no warnings (R 4.6.1, testthat 3.3.2, Linux x86_64).