weight_sl_convex: Convex ensemble weights for super learner

Description Usage Arguments Details Value Examples

Description

In general, the function passed to sl_control$weight_fn should expect a list of named lists of outcomes (Y), predictions (pred) in validation folds. Typically, this function is used to maximize sl_control$optim_risk_fn over weights. The function should return a named list. One of the names in the list should be weight, which is the optimized weights. Other entries in the return list are passed on to sl_control$cv_risk_fn (e.g., things needed to compute cross-validated measure of association, though none are present for this particular function).

Usage

1
weight_sl_convex(input, sl_control)

Arguments

input

A list where each entry corresponds to a validation fold. Each entry is a list with entries: Y (univariate outcome for this validation fold), pred (matrix of predictions from learner and columns correspond to different learner).

sl_control

Super learner control options.

Details

In this case, the function uses Rsolnp::solnp to minimize sl_control$optim_risk_fn over convex weights.

Value

Numeric vector giving convex weights for the super learner.

Examples

1
2
3
4
5
6
7
8
#Simulate data with proper format:
inp <- list(list(Y = rnorm(50), pred = cbind(rnorm(50), rnorm(50))))

#Linear ensemble minimizing mean squared-error:
sl_control <- list(ensemble_fn = "ensemble_linear", optim_risk_fn = "optim_risk_sl_se")

#Get weights to minimize optim_risk:
sl_weight <- weight_sl_convex(inp, sl_control)

benkeser/cvma documentation built on May 5, 2019, 1:37 p.m.