modifySL: modifySL

Description Usage Arguments Value Examples

Description

Recompute the super learner estimator from a SuperLearner fit based on a restricted set of candidate learners and/or a different loss function than initially fit. Note that this function does not check for errors in the original SuperLearner fit library as well as the SuperLearner function does. In essence, I'm assuming you've already decided to get rid of the learners that had errors in the initial fitting procedure for computing this new Super Learner.

Usage

1
2
modifySL(fit, newLibrary = fit$libraryNames, newMethod = fit$method,
  obsWeights = rep(1, length(fit$SL.predict)), verbose = FALSE, ...)

Arguments

fit

An object of class SuperLearner

newLibrary

A character vector of a subset of fit$libraryNames.

newMethod

A list structured as a SuperLearner method. See ?write.method.template.

obsWeights

The weights used to compute the original Super Learner fit. Because these weights are not returned with the SuperLearner object, they must be input again here.

verbose

Passed to the method functions to print option messages.

...

Other options. Currently not used.

Value

An object of \classSuperLearner with modifications recorded. See ?SuperLearner for details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
n <- 100
X <- data.frame(x1=runif(n), x2=rnorm(n), x3=rbinom(n,1,0.5))
Y <- rnorm(n, X$x1 + X$x3)

# fit a super learner with library of three
set.seed(1234)
sl1 <- SuperLearner(Y=Y, X=X, SL.library=c("SL.glm","SL.gam","SL.mean"))

# recompute super learner omitting SL.gam
sl2 <- modifySL(fit = sl1, newLibrary = c("SL.glm_All","SL.mean_All"))

# should be the same as this super learner 
set.seed(1234)
sl3 <- SuperLearner(Y=Y, X=X, SL.library=c("SL.glm","SL.mean"))

# can also modify super learner method
sl4 <- modifySL(fit = sl1, newMethod = "method.CC_LS")

# should be the same as this 
set.seed(1234)
sl5 <- SuperLearner(Y=Y, X=X, SL.library = c("SL.glm","SL.gam","SL.mean"), 
method = "method.CC_LS")

# can also modify both simultaneously
sl6 <- modifySL(fit = sl1, newLibrary = c("SL.glm_All","SL.mean_All"),
newMethod = "method.CC_LS")

# same as this
set.seed(1234)
sl7 <- SuperLearner(Y=Y, X=X, SL.library = c("SL.glm","SL.mean"), 
method = "method.CC_LS")

benkeser/modifySL documentation built on May 12, 2019, 12:08 p.m.