Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Pareto k-value warnings, use loo::sis() for weighted draws #438

Merged
merged 26 commits into from
Aug 10, 2023

Conversation

fweber144
Copy link
Collaborator

@fweber144 fweber144 commented Aug 10, 2023

This PR improves the Pareto k-value warnings by suppressing the original warnings from the loo package and throwing customized warnings instead (thank you, @n-kall, for the suggestion).

While implementing this, I realized that if the projected draws used for the performance evaluation in the validate_search = FALSE case have different weights, then loo::sis() needs to be used instead of loo::psis() (because the weights would need to be taken into account when performing the Pareto smoothing). Hence, this fallback to loo::sis() is implemented here as well (and apart from that, we now use loo::sis() explicitly if loo::psis() would not perform the Pareto smoothing due to a small number of draws, but this is merely a safety measure, see the inline comments added in the code).

In order to differentiate between different warnings in the unit tests, other warnings are now thrown conditionally on their own "hidden" global options.

Some enhancements for capture.output() usage in fit_cumul() and fit_cumul_mlvl() are included as well (found when starting to use capture.output() in loo_varsel()).

Also added is a unit test that the warning for full Gaussian multilevel models added in #426 is thrown correctly (this test required the differentiation between different warnings, so it is included here).

…(they

are `Inf` in that case), throw the PSIS warnings conditionally on global
option `projpred.warn_psis`, and add a `TODO`.
…` (see

the newly added inline comments for details).
weights (constant weights are necessary because nonconstant weights would have
to be incorporated into the Pareto smoothing).
`capture.output()` to filter out some of them.
…ditionally on global option `projpred.warn_kfold_refits`.
…bal option `projpred.warn_instable_projections`.
`validate_search = FALSE` submodel performance evaluation to refer to the
original-draws (formerly: "complete-draws") Pareto k-values:

Only checking for no original-draws Pareto k-values > 0.7 is not enough. When
done precisely, the Pareto k-values themselves would need to be compared.
`testthat::test_that()` seems to redirect warning messages (probably so that it
can throw them itself) so they are not captured correctly by `capture.output()`.
@fweber144 fweber144 merged commit 389d932 into stan-dev:master Aug 10, 2023
@fweber144 fweber144 deleted the psis_warnings_etc branch August 10, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant