weight_y_01: Find single outcome with best risk

Description Usage Arguments Details Value Examples

Description

In general, the function passed to y_weight_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 y_weight_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 y_weight_control$cv_risk_fn (e.g., things needed to compute cross-validated measure of association).

Usage

1
weight_y_01(input, y_weight_control)

Arguments

input

A list where each entry corresponds to a validation fold. Each entry of input is a list with entries: Y (matrix of outcomes for this validation fold), pred (matrix of super learner predictions for each outcomes with columns corresponding to different outcomes).

y_weight_control

Composite outcome weight control options.

Details

In this case, the function searches over all outcomes for the single outcome that minimizes y_weight_control$optim_risk_fn.

Value

List with named components weight (optimized weights) and ybar (marginal mean outcome for optimized weights, used to compute the cross-validated nonparametric R-squared).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# simulate data with proper format
input <- list(list(Y = cbind(rbinom(50,1,0.5), rbinom(50,1,0.5)), 
                   pred = cbind(runif(50,0,1), runif(50,0,1)),
                   y_weight = list(weight = c(0.5, 0.5))),
                   list(Y = cbind(rbinom(50,1,0.5), rbinom(50,1,0.5)),
                   pred = cbind(runif(50,0,1), runif(50,0,1)),
                   y_weight = list(weight = c(0.25, 0.75))))

# linear combination of outcomes ok with 0/1 weights
y_weight_control <- list(ensemble_fn = "ensemble_linear",
                         optim_risk_fn = "optim_risk_y_auc")

# get risk 
weight <- weight_y_01(input, y_weight_control)

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