Repository navigation
Fix full-data dis in K-fold reference models of get_refmodel.stanreg() - #587
Merged
Merged
Conversation
aloctavodia
approved these changes
Nov 6, 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.
In
get_refmodel.stanreg(),cvrefbuilderpassesdis = dis, and the function setsdisto the full-datasigmadraws only after definingcvrefbuilder. R evaluatesdiswhencvrefbuilderruns, so incv_varsel(cv_method = "kfold")every fold-wise reference model of a Gaussian model used the full-datasigmainstead of thesigmaof its own refit. The fix passes the user-supplieddis(usuallyNULL), so each fold takessigmafrom its refit. The new test intest_refmodel.Rfails without the fix.Effect, measured on Gaussian
stan_glm()models with 10-fold CV (N 30 to 400, P 5 and 25, 100 simulated data sets per cell): the old code overestimated the reference model's elpd by about 1 for every N. For N ≥ 100, it overestimated the submodels' elpd by 0.15 to 1, growing with the submodel size; that is at most 0.15 SE on average, and up to 0.7 SE for N 30. The rankings do not change, but the suggested size changed in up to 13 % of the data sets.brms has the same pattern in
get_refmodel.brmsfit(), which needs a separate PR.This PR was assisted by Claude