diff --git a/NEWS.md b/NEWS.md index 36f3dc49d..743da9c81 100644 --- a/NEWS.md +++ b/NEWS.md @@ -27,6 +27,7 @@ If you read this from a place other than $ppd() functions used by proj_predict(): +parse_wobs_ppd <- function(wobs, n_obs) { + if (length(wobs) == 0) { + wobs <- rep(1, n_obs) + } else if (length(wobs) == 1) { + wobs <- rep(wobs, n_obs) + } else if (length(wobs) != n_obs) { + stop("Argument `wobs` needs to be of length 0, 1, or the number of ", + "observations.") + } + if (!all(wobs == 1) && getOption("projpred.warn_wobs_ppd", TRUE)) { + warning("Currently, proj_predict() ignores observation weights not equal ", + "to `1`.") + } + return(wobs) +} diff --git a/man/pred-projection.Rd b/man/pred-projection.Rd index 918045df4..aa3b69d18 100644 --- a/man/pred-projection.Rd +++ b/man/pred-projection.Rd @@ -152,6 +152,9 @@ submodels at once (for \code{object}s of class \code{vsel} or \code{object}s ret \code{\link[=project]{project()}} call to an object of class \code{vsel}; see \code{\link[=project]{project()}}). } \details{ +Currently, \code{\link[=proj_predict]{proj_predict()}} ignores observation weights that are not +equal to \code{1}. A corresponding warning is thrown if this is the case. + In case of the latent projection and \code{transform = FALSE}: \itemize{ \item Output element \code{pred} contains the linear predictors without any diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index f35d17ef6..001697675 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -812,6 +812,9 @@ meth_tst <- list( # Suppress the warning for interaction terms being selected before all involved # main effects have been selected (only concerns L1 search): options(projpred.warn_L1_interactions = FALSE) +# Suppress the warning thrown by proj_predict() in case of observation weights +# that are not all equal to `1`: +options(projpred.warn_wobs_ppd = FALSE) search_trms_tst <- list( default_search_trms = list(),