weight_sl_01: 0/1 weights for super learner (i.e., discrete 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_01(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 leaners).

sl_control

Super learner control options.

Details

In this case, the function selects the single outcome with the lowest value returned by sl_control$optim_risk_fn

Value

Numeric vector giving 0/1 weights for super learner.

Examples

1
2
3
4
5
6
7
8
#Simulate data and properly format:
input <- list(list(Y = rbinom(50,1,0.5), pred = cbind(rnorm(50), rnorm(50))))

#Linear ensemble
sl_control <- list(ensemble_fn = "ensemble_linear", optim_risk_fn = "optim_risk_sl_auc")

#Get weights to minimize optim_risk:
sl_weight <- weight_sl_01(input, sl_control)

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