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

projpred-related seed fix and docs/NEWS #1502

Merged
merged 6 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ all additive predictor terms specified in the same formula. (#1492)
and incompatible with the newly implemented global shrinkage prior framework.
* No longer support multiple deprecated prior options for categorical and
multivariate models after around 3 years of deprecation. (#1420)
* Deprecate argument `newdata` of `get_refmodel.brmsfit()`. (#1502)

### Bug Fixes

Expand Down Expand Up @@ -95,6 +96,7 @@ over-dispersed and zero-inflated binomial response models thanks to Hayden
Rabel. (#1319 & #1311)
* Display `ppd_*` plots in `pp_check` via argument `prefix`. (#1313)
* Support the `log` link in binomial and beta type families. (#1316)
* Support **projpred**'s augmented-data projection. (#1292, #1294)

### Other changes

Expand Down
11 changes: 10 additions & 1 deletion R/projpred.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#' \code{TRUE} requires a \pkg{projpred} version >= 2.4.0.
#' @param brms_seed A seed used to infer seeds for \code{\link{kfold.brmsfit}}
#' and for sampling group-level effects for new levels (in multilevel models).
#' If \code{NULL}, then \code{\link{set.seed}} is not called at all. If not
#' \code{NULL}, then the pseudorandom number generator (PRNG) state is reset
#' (to the state before calling this function) upon exiting this function.
#' @param ... Further arguments passed to
#' \code{\link[projpred:init_refmodel]{init_refmodel}}.
#'
Expand Down Expand Up @@ -66,9 +69,11 @@ get_refmodel.brmsfit <- function(object, newdata = NULL, resp = NULL,
# Infer "sub-seeds":
if (exists(".Random.seed", envir = .GlobalEnv)) {
rng_state_old <- get(".Random.seed", envir = .GlobalEnv)
on.exit(assign(".Random.seed", rng_state_old, envir = .GlobalEnv))
}
if (!is.null(brms_seed)) {
if (exists(".Random.seed", envir = .GlobalEnv)) {
on.exit(assign(".Random.seed", rng_state_old, envir = .GlobalEnv))
}
set.seed(brms_seed)
}
kfold_seed <- sample.int(.Machine$integer.max, 1)
Expand Down Expand Up @@ -186,6 +191,10 @@ get_refmodel.brmsfit <- function(object, newdata = NULL, resp = NULL,
}

# prepare data passed to projpred
if (!is.null(newdata)) {
warning2("Argument 'newdata' of get_refmodel.brmsfit() is deprecated and ",
"will be removed in the future.")
}
data <- current_data(
object, newdata, resp = resp, check_response = TRUE,
allow_new_levels = TRUE
Expand Down
5 changes: 4 additions & 1 deletion man/get_refmodel.brmsfit.Rd

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