A step of the flxipt_native implementation. Called by flexible_iptw.
See the file header for the source the module follows.
Usage
super_learner(
y,
X,
library = NULL,
n_folds = 10,
meta = "nnls",
binary = NULL,
loss = "l2",
ridge = 1e-08,
honest_level_one = TRUE
)Arguments
- y
Coerced to numeric by the body, with
as.numeric.- X
Optional; may be
NULL. A matrix; passed toas.matrix.- library
The body requires: flxipt: the library is empty.
- n_folds
Passed to
.flxipt_folds. Defaults to10.- meta
One of
"discrete","nnls". Defaults to"nnls".- binary
Optional; may be
NULL. A flag; the body branches on it.- loss
Compared against
"nll". Defaults to"l2".- ridge
Numeric; passed to
max. Defaults to1e-08.- honest_level_one
A flag; the body branches on it. Defaults to
TRUE.
Value
A list with fitted, estimate, weights,
weight_vector, cv_risk, cv_risk_ensemble, best_candidate,
best_candidate_risk, discrete_choice, level_one,
candidate_fits, library, n, n_folds, meta,
loss, binary, honest_level_one, method.
Examples
set.seed(1)
n <- 40
X <- matrix(rnorm(n * 2), n, 2)
y <- 1 + X[, 1] - 0.5 * X[, 2] + rnorm(n, 0, 0.3)
r <- super_learner(y, X, n_folds = 4)
str(r, max.level = 1)
#> List of 19
#> $ fitted : num [1:40] 0.5346 1.3092 -0.0221 2.2486 1.6271 ...
#> $ estimate : num 0.0602
#> $ weights : Named num [1:6] 0 1 0 0 0 0
#> ..- attr(*, "names")= chr [1:6] "intercept" "main" "quadratic" "interaction" ...
#> $ weight_vector : num [1:6] 0 1 0 0 0 0
#> $ cv_risk : Named num [1:6] 0.7277 0.0602 0.0668 0.0644 0.068 ...
#> ..- attr(*, "names")= chr [1:6] "intercept" "main" "quadratic" "interaction" ...
#> $ cv_risk_ensemble : num 0.0602
#> $ best_candidate : chr "main"
#> $ best_candidate_risk: num 0.0602
#> $ discrete_choice : chr "main"
#> $ level_one : num [1:40, 1:6] 1.078 1.083 0.964 1.143 1.078 ...
#> $ candidate_fits : num [1:40, 1:6] 1.07 1.07 1.07 1.07 1.07 ...
#> $ library : chr [1:6] "intercept" "main" "quadratic" "interaction" ...
#> $ n : int 40
#> $ n_folds : int 4
#> $ meta : chr "nnls"
#> $ loss : chr "l2"
#> $ binary : logi FALSE
#> $ honest_level_one : logi TRUE
#> $ method : chr "Super Learner, van der Laan, Polley & Hubbard (2007) Sec. 2 eq. (1)"
