Function that computes the optimal combination of multiple outcomes and a predictor of the optimal combination using Super Learning.
optWeight(Y, X, SL.library, family = "gaussian", CV.SuperLearner.V = 10, seed = 12345, whichAlgorithm = "SuperLearner", return.SuperLearner = TRUE, return.CV.SuperLearner = FALSE, return.IC = TRUE, parallel = FALSE, n.cores = parallel::detectCores(), ...)
Y | A |
---|---|
X | A |
SL.library | A |
family | An object of class |
CV.SuperLearner.V | The number of CV folds for the calls to |
seed | The seed to set before each internal call to |
whichAlgorithm | What algorithm to compute optimal predictions and R^2 values for. |
return.SuperLearner | A |
return.CV.SuperLearner | A |
return.IC | A |
parallel | A |
n.cores | A |
... | Other arguments |
TO DO: Add return documentation.
# Example 1 -- simple fit set.seed(1234) X <- data.frame(x1=runif(n=100,0,5), x2=runif(n=100,0,5)) Y1 <- rnorm(100, X$x1 + X$x2, 1) Y2 <- rnorm(100, X$x1 + X$x2, 3) Y <- data.frame(Y1 = Y1, Y2 = Y2) fit <- optWeight(Y = Y, X = X, seed = 1, SL.library = c("SL.glm","SL.mean","SL.step")) # Example 2 -- simple fit with parallelization #system.time( # fit <- optWeight(Y = Y, X = X, SL.library = c("SL.glm","SL.mean","SL.step"), #parallel = TRUE, n.cores = 3) #)