Skip to content

Commit

Permalink
Since summaries_fast is created by a call to loo_varsel() with
Browse files Browse the repository at this point in the history
`validate_search = FALSE`, the search is not run again when creating
`summaries_fast`. Only the performance evaluation (including the re-projections
required for it) is run again. Hence, it would be inconsistent to treat
`summaries_fast` like the search-related arguments of `cv_varsel.refmodel()`
when calling `cv_varsel.refmodel()` from within `cv_varsel.vsel()`. Thus, a lot
of code related to `summaries_fast` can be removed, which is done here.
  • Loading branch information
fweber144 committed Oct 9, 2024
1 parent 7469aea commit 0dcfcf2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
9 changes: 3 additions & 6 deletions R/cv_varsel.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#' of the selected submodels are optimistically biased. However, these fast
#' biased estimated can be useful to obtain initial information on the
#' usefulness of projection predictive variable selection.
#' @param summaries_fast **TODO**
#' @param seed Pseudorandom number generation (PRNG) seed by which the same
#' results can be obtained again if needed. Passed to argument `seed` of
#' [set.seed()], but can also be `NA` to not call [set.seed()] at all. If not
Expand Down Expand Up @@ -188,8 +187,7 @@ cv_varsel.vsel <- function(
) {
## the following arguments should not change
arg_nms_internal <- c("method", "ndraws", "nclusters", "nterms_max",
"search_control", "penalty", "search_terms",
"summaries_fast")
"search_control", "penalty", "search_terms")
dots <- list(...)
arg_nms_internal_used <- intersect(arg_nms_internal, names(dots))
for (arg in arg_nms_internal_used) {
Expand Down Expand Up @@ -243,7 +241,6 @@ cv_varsel.vsel <- function(
search_control = object[["args_search"]][["search_control"]],
penalty = object[["args_search"]][["penalty"]],
search_terms = object[["args_search"]][["search_terms"]],
summaries_fast = object[["summaries_fast"]],
cv_method = cv_method,
nloo = nloo,
K = K,
Expand Down Expand Up @@ -280,7 +277,6 @@ cv_varsel.refmodel <- function(
seed = NA,
search_terms = NULL,
search_out = NULL,
summaries_fast = NULL,
parallel = getOption("projpred.prll_cv", FALSE),
...) {
if (!missing(lambda_min_ratio)) {
Expand Down Expand Up @@ -387,6 +383,7 @@ cv_varsel.refmodel <- function(
search_out_rks <- NULL
}

summaries_fast <- NULL
if (cv_method == "LOO") {
sel_cv <- loo_varsel(
refmodel = refmodel, method = method, nterms_max = nterms_max,
Expand All @@ -405,7 +402,7 @@ cv_varsel.refmodel <- function(
search_terms_was_null = search_terms_was_null,
search_out_rks = search_out_rks, parallel = parallel, ...
)
if (is.null(summaries_fast) && validate_search && nloo < refmodel$nobs) {
if (validate_search && nloo < refmodel$nobs) {
# Run fast LOO-CV to be used in subsampling difference estimator
summaries_fast <- loo_varsel(
refmodel = refmodel, method = method, nterms_max = nterms_max,
Expand Down
3 changes: 0 additions & 3 deletions man/cv_varsel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0dcfcf2

Please sign in to comment.