recombineSL | R Documentation |

The `recombineSL`

function takes an existing SuperLearner fit and a new metalearning method and returns a new SuperLearner fit with updated base learner weights.

```
recombineSL(object, Y, method = "method.NNloglik", verbose = FALSE)
```

`object` |
Fitted object from |

`Y` |
The outcome in the training data set. Must be a numeric vector. |

`method` |
A list (or a function to create a list) containing details on estimating the coefficients for the super learner and the model to combine the individual algorithms in the library. See |

`verbose` |
logical; TRUE for printing progress during the computation (helpful for debugging). |

`recombineSL`

re-fits the super learner prediction algorithm using a new metalearning method. The weights for each algorithm in `SL.library`

are re-estimated using the new metalearner, however the base learner fits are not regenerated, so this function saves a lot of computation time as opposed to using the `SuperLearner`

function with a new `method`

argument. The output is identical to the output from the `SuperLearner`

function.

`call` |
The matched call. |

`libraryNames` |
A character vector with the names of the algorithms in the library. The format is 'predictionAlgorithm_screeningAlgorithm' with '_All' used to denote the prediction algorithm run on all variables in X. |

`SL.library` |
Returns |

`SL.predict` |
The predicted values from the super learner for the rows in |

`coef` |
Coefficients for the super learner. |

`library.predict` |
A matrix with the predicted values from each algorithm in |

`Z` |
The Z matrix (the cross-validated predicted values for each algorithm in |

`cvRisk` |
A numeric vector with the V-fold cross-validated risk estimate for each algorithm in |

`family` |
Returns the |

`fitLibrary` |
A list with the fitted objects for each algorithm in |

`varNames` |
A character vector with the names of the variables in |

`validRows` |
A list containing the row numbers for the V-fold cross-validation step. |

`method` |
A list with the method functions. |

`whichScreen` |
A logical matrix indicating which variables passed each screening algorithm. |

`control` |
The |

`cvControl` |
The |

`errorsInCVLibrary` |
A logical vector indicating if any algorithms experienced an error within the CV step. |

`errorsInLibrary` |
A logical vector indicating if any algorithms experienced an error on the full data. |

Erin LeDell ledell@berkeley.edu

van der Laan, M. J., Polley, E. C. and Hubbard, A. E. (2008) Super Learner, *Statistical Applications of Genetics and Molecular Biology*, **6**, article 25.

```
## Not run:
# Binary outcome example adapted from SuperLearner examples
set.seed(1)
N <- 200
X <- matrix(rnorm(N*10), N, 10)
X <- as.data.frame(X)
Y <- rbinom(N, 1, plogis(.2*X[, 1] + .1*X[, 2] - .2*X[, 3] +
.1*X[, 3]*X[, 4] - .2*abs(X[, 4])))
SL.library <- c("SL.glmnet", "SL.glm", "SL.knn", "SL.mean")
# least squares loss function
set.seed(1) # for reproducibility
fit_nnls <- SuperLearner(Y = Y, X = X, SL.library = SL.library,
verbose = TRUE, method = "method.NNLS", family = binomial())
fit_nnls
# Risk Coef
# SL.glmnet_All 0.2439433 0.01293059
# SL.glm_All 0.2461245 0.08408060
# SL.knn_All 0.2604000 0.09600353
# SL.gam_All 0.2471651 0.40761918
# SL.mean_All 0.2486049 0.39936611
# negative log binomial likelihood loss function
fit_nnloglik <- recombineSL(fit_nnls, Y = Y, method = "method.NNloglik")
fit_nnloglik
# Risk Coef
# SL.glmnet_All 0.6815911 0.1577228
# SL.glm_All 0.6918926 0.0000000
# SL.knn_All Inf 0.0000000
# SL.gam_All 0.6935383 0.6292881
# SL.mean_All 0.6904050 0.2129891
# If we use the same seed as the original `fit_nnls`, then
# the recombineSL and SuperLearner results will be identical
# however, the recombineSL version will be much faster since
# it doesn't have to re-fit all the base learners.
set.seed(1)
fit_nnloglik2 <- SuperLearner(Y = Y, X = X, SL.library = SL.library,
verbose = TRUE, method = "method.NNloglik", family = binomial())
fit_nnloglik2
# Risk Coef
# SL.glmnet_All 0.6815911 0.1577228
# SL.glm_All 0.6918926 0.0000000
# SL.knn_All Inf 0.0000000
# SL.gam_All 0.6935383 0.6292881
# SL.mean_All 0.6904050 0.2129891
## End(Not run)
```

SuperLearner documentation built on July 26, 2023, 6:05 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.