Learn R Programming

vimp (version 2.0.1)

sp_vim: Shapley Population Variable Importance Measure (SPVIM) estimates

Description

Compute estimates and confidence intervals for the SPVIMs, using cross-validation. This essentially involves splitting the data into V train/test splits; train the learners on the training data, evaluate importance on the test data; and average over these splits.

Usage

sp_vim(
  Y,
  X,
  V = 5,
  weights = rep(1, length(Y)),
  type = "r_squared",
  SL.library = c("SL.glmnet", "SL.xgboost", "SL.mean"),
  gamma = 1,
  alpha = 0.05,
  delta = 0,
  na.rm = FALSE,
  ...
)

Arguments

Y

the outcome.

X

the covariates.

V

the number of folds for cross-validation, defaults to 10.

weights

weights for the computed influence curve (e.g., inverse probability weights for coarsened-at-random settings)

type

the type of parameter (e.g., R-squared-based is "r_squared").

SL.library

a character vector of learners to pass to SuperLearner, if f1 and f2 are Y and X, respectively. Defaults to SL.glmnet, SL.xgboost, and SL.mean.

gamma

the fraction of the sample size to use when sampling subsets (e.g., gamma = 1 samples the same number of subsets as the sample size)

alpha

the level to compute the confidence interval at. Defaults to 0.05, corresponding to a 95% confidence interval.

delta

the value of the \(\delta\)-null (i.e., testing if importance < \(\delta\)); defaults to 0.

na.rm

should we remove NA's in the outcome and fitted values in computation? (defaults to FALSE)

...

other arguments to the estimation tool, see "See also".

Value

An object of class vim. See Details for more information.

Details

See the paper by Williamson and Feng (2020) for more details on the mathematics behind this function, and the validity of the confidence intervals. The function works by estimating In the interest of transparency, we return most of the calculations within the vim object. This results in a list containing:

  • call - the call to cv_vim

  • SL.library - the library of learners passed to SuperLearner

  • v- the estimated predictiveness measure for each sampled subset

  • preds_lst - the predicted values from the chosen method for each sampled subset

  • est - the estimated SPVIM value for each feature

  • ic_lst - the influence functions for each sampled subset

  • ic- a list of the SPVIM influence function contributions

  • se - the standard errors for the estimated variable importance

  • ci - the \((1-\alpha) \times 100\)% confidence intervals based on the variable importance estimates

  • gamma- the fraction of the sample size used when sampling subsets

  • alpha - the level, for confidence interval calculation

  • delta- the delta value used for hypothesis testing

  • y - the outcome

  • weights - the weights

  • mat- a tibble with the estimates, SEs, CIs, hypothesis testing decisions, and p-values

See Also

SuperLearner for specific usage of the SuperLearner function and package.

Examples

Run this code
# NOT RUN {
## don't test because this can take some time to run
library(SuperLearner)
library(gam)
n <- 100
p <- 2
## generate the data
x <- data.frame(replicate(p, stats::runif(n, -5, 5)))

## apply the function to the x's
smooth <- (x[,1]/5)^2*(x[,1]+7)/5 + (x[,2]/3)^2

## generate Y ~ Normal (smooth, 1)
y <- as.matrix(smooth + stats::rnorm(n, 0, 1))

## set up a library for SuperLearner
learners <- c("SL.mean", "SL.gam")

## -----------------------------------------
## using Super Learner
## -----------------------------------------
set.seed(4747)
est <- sp_vim(Y = y, X = x, V = 5, type = "r_squared", SL.library = learners, alpha = 0.05)
# }

Run the code above in your browser using DataLab