Repository navigation
Fix the error of cv_varsel() with LOO and the latent projection for an NA Pareto k of loo::E_loo() - #667
Merged
Conversation
… threshold for the draws of each k
…for an unestimated k in the tests
…ad of counting NA as Inf
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.
Summary
cv_varsel()withcv_method = "LOO"and the latent projection stops with "missing value where TRUE/FALSE needed" ifloo::E_loo()gives anNAPareto k. This happens if most of the PSIS-LOO ratios of an observation underflow to 0, for example with a non-converged reference model. For such an observation,loo::psis()gives a Pareto k ofInf.Change
cv_varsel()has the Pareto k of the ratios from its ownloo::psis()call. With this PR, the warning about the latent response values counts each observation with the larger of this k and theloo::E_loo()k. If theloo::E_loo()k isNA, it counts with theloo::psis()k. This is the rule of stan-dev/loo#421, whereloo::E_loo()takes the k of the ratios from thepsis()object. With the loo version of stan-dev/loo#421, this rule does not change the count. projpred needs the rule for loo 2.10.1.Other changes
warn_pareto()now gets the k values and the number of draws. It computes the threshold and the number of k values above it..ps_khat_threshold()now usesposterior::ps_khat_threshold(), capped at 0.7 as in loo.loo::psis()warning that projpred replaces does. So this warning can occur more often, for example with a smallnclusters_pred.Tests
New tests in
test_pareto_k.Rcover the threshold,warn_pareto()and twocv_varsel()cases:nclusters_pred = 30.With the
R/cv_varsel.Rof master, the latent test gives the error above, and the submodel warning counts 1 of 30 k values instead of 5.The full suite passes with
NOT_CRAN=true, R 4.6.1, loo 2.10.1.9000 and posterior 1.7.1 (62,669 expectations, 0 failures). This run was before the merge of the master commit of #662. After that merge,test_pareto_k.R,test_latent.R,test_search_latent.R,test_search_screen.R,test_augdat_ll.Randtest_loo_weight_perturbation.Rpass.test_pareto_k.Ralso passes with the loo branch of stan-dev/loo#421 and posterior 1.8.0.This PR was assisted by Claude.