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

Fix performance summary bugs for subsampled PSIS-LOO CV #475

Merged
merged 15 commits into from
Nov 9, 2023

Conversation

fweber144
Copy link
Collaborator

This fixes several bugs (mainly in get_stat()) that were sometimes causing incorrect predictive performance results (i.e., point estimate, standard error, confidence interval) in case of subsampled PSIS-LOO CV. For details, see the commit messages.

…s = TRUE`:

If `mu.bs` has `NA`s (which is the case for subsampled PSIS-LOO CV if
`baseline = "best"`), then `mu` gets modified by line `mu[is.na(mu.bs)] <- NA`
and hence `auc.data` needs to be updated as well.
Previously, `NA` was returned as the AUC for the submodels. This was due to
`NA`s not being handled correctly in `auc()`.
subsampled PSIS-LOO CV (`nloo`) with `deltas = TRUE` and `baseline = "best"`.

For `baseline = "ref"`, this is only a refactor improving the safety and
readability of `get_stat()`'s handling of `NA`s because for `baseline = "ref"`,
we should always have no `NA`s in `lppd.bs` and `mu.bs`, so in that case,
`n_notna` did not require an adjustment and also because the math operations
connecting `mu` and `mu.bs` (analogously for `lppd` and `lppd.bs`) ensured that
only the "inner join" of non-`NA` elements (i.e., the set of observations for
which both `mu` and `mu.bs` (analogously for `lppd` and `lppd.bs`) are not `NA`)
is used.

This addresses question 1 from
<stan-dev#94 (comment)>.
Previously,
```r
weighted.sd(numeric(), numeric())
weighted.sd(NA, NA)
weighted.sd(NA, NA, na.rm = TRUE)
weighted.sd(0.42, 42)
```
returned `0`, `NA_real_`, `0`, `NaN`, respectively. Now, they return `NA_real_`,
`NA_real_`, `NA_real_`, `NA_real_`, respectively, just like
```r
sd(numeric())
sd(NA)
sd(NA, na.rm = TRUE)
sd(0.42)
```
.
`stat %in% c("acc", "pctcorr", "auc")` and `!is.null(y_wobs_test$y_prop)`:
`n_notna` was not adapted correctly in that case (because `y_wobs_test$wobs`
usually has non-`NA`s at those places where `mu` has `NA`s).
@fweber144 fweber144 mentioned this pull request Nov 9, 2023
@fweber144 fweber144 merged commit ca46327 into stan-dev:master Nov 9, 2023
@fweber144 fweber144 deleted the fix_stats_nloo branch November 9, 2023 21:06
fweber144 added a commit to fweber144/projpred that referenced this pull request Nov 14, 2023
from PR stan-dev#475:

Since `.tabulate_stats()` gets arguments from `summary.vsel()` and friends via
`...` and passes them over to `get_stat()`, omitting argument `wcv` would have
made it possible for users to modify it.
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