Description Usage Arguments Details Value Examples
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 minimize 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).
1 | weight_y_convex(input, y_weight_control)
|
input |
A list where each entry corresponds to a validation fold. Each entry of |
y_weight_control |
Composite outcome weight control options. |
In this case, the function uses Rsolnp::solnp
to minimize
y_weight_control$optim_risk_fn
over convex weights. In addition to the optimized weights, the function
returns the marginal mean of the composite outcome based on the optimized weights,
which is used by cv_risk_y_r2
to compute the cross-validated nonparametric
R-squared.
List with named components weight (optimized weights) and ybar (marginal mean outcome for optimized weights, used to compute the cross-validated nonparametric R-squared).
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
y_weight_control <- list(ensemble_fn = "ensemble_linear",
optim_risk_fn = "optim_risk_y_r2")
# get risk
weight <- weight_y_convex(input, y_weight_control)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.