Repository navigation
Add Monte Carlo diagnostics for the elpd of LOO-CV - #432
florence-bockting wants to merge 37 commits into
Conversation
… the code and the paper
…dian, as the paper and loobench
…re alpha in mixis_n_eff()
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #432 +/- ##
==========================================
+ Coverage 92.82% 93.30% +0.48%
==========================================
Files 31 37 +6
Lines 3078 3510 +432
==========================================
+ Hits 2857 3275 +418
- Misses 221 235 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 5c04520 is merged into master:
Further explanation regarding interpretation and methodology can be found in the documentation. |
|
Looks good. In addition of going through the code myself, here are Claude assisted findings
|
Summary
Adds Monte Carlo diagnostics for the elpd estimate of LOO-CV. Each of the four
cv_functions returns the estimate together with its MCSE, bias and predicted RMSE. Each function warns when the estimate fails its trust rule.New exported functions
cv_psis(x, chain_id, psis_object)ps_khat_threshold()cv_mixis(x, alpha, chain_id)cv_brute_force(x, log_lik_full, chain_id)cv_bridge(x, log_lik_full, chain_id, chain_id_full)mixis_alpha(): balanced mixture weights from a PSIS result.mixis_n_eff(): the predicted ESS of the MixIS weights for a candidatealpha.The
cv_elpdclassestimates: totalelpd,mcse,bias,rmse.pointwise:elpd,mcse_elpd,bias_elpdper fold.diagnostics: depends on the method (Pareto k, r_eff, gap, ...).mc_error$interval: the 95% MC interval of the exact total elpd.print(),print_dims(),dim(),as.data.frame().Warnings
loo_warning_cv_elpd_untrusted.loo_warning_pareto_k_high. This warning is not part of the trust rule.Agreement with the reference implementation
The values were cross-checked against loobench on four cases: base, heavy tail (k = 1.36), autocorrelated chains, and LOGO. All methods agree to >= 0.9997. There is one exception: the MixIS bias in the heavy-tail case.
In that case loobench calls
ess_mean()on unscaled weights (max 7e-79).is_constant()then gives NA, and the ESS falls back to S. This PR rescales the weights first (ESS 4024), as the paper does.Tests
New files:
test_cv_psis.R,test_cv_mixis.R,test_cv_brute_force.R,test_cv_bridge.R,test_cv_elpd.R, plus a snapshot file and one case intest_warning_classes.R.In this PR I used LLM assistance.