mpersonalized_cv: Cross Validation for 'mpersonalized'

Description Usage Arguments Value Examples

Description

This function implments mpersonalized and use cross validatation to tune penalty parameter. The optimal penalty parameter is selected by minimizing

∑_{i=1}^{n_k}\frac{|\hat{C}_k(X_{i})|}{∑_{i=1}^{n_k}|\hat{C}_k(X_{i})|}\bigl [1\{\hat{C}_k(X_{i})>0\}-g_k(X_{i})\bigr]^2

in the leave-out fold, where \hat{C}_k(X_{i}) in the leave-out fold is independently estimated from the training set.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mpersonalized_cv(problem = c("meta-analysis", "multiple outcomes"), X,
  Trt, P = NULL, Xlist, Ylist, Trtlist,
  Plist = replicate(length(Xlist), NULL, simplify = FALSE),
  typelist = replicate(length(Xlist), "continuous", simplify = FALSE),
  penalty = c("lasso", "GL", "SGL", "fused", "lasso+fused", "GL+fused",
  "SGL+fused", "SGL+SL"), lambda1 = NULL, lambda2 = NULL,
  tau0 = NULL, single_rule_lambda = NULL,
  num_lambda1 = ifelse(!is.null(lambda1), length(lambda1), 10),
  num_lambda2 = ifelse(!is.null(lambda2), length(lambda2), 10),
  num_tau0 = ifelse(!is.null(tau0), length(tau0), 11), min_tau = 0.01,
  num_single_rule_lambda = ifelse(!is.null(single_rule_lambda),
  length(single_rule_lambda), 50), alpha = NULL, single_rule = FALSE,
  cv_folds = 5, admm_control = NULL, contrast_builder_control = NULL)

Arguments

problem

A character string specifiy whether user want to solve "meta-analysis" or "multiple outcomes" problem. For problem = "meta-analysis", user should also supply Xlist, Ylist, Trtlist. For problem = "multiple outcomes", user should supply X, Ylist, Trt.

X

Covariate matrix that should be supplied when problem = "multiple outcomes" with rows indicating subjects and columns indicating covariates.

Trt

Treatment vector that should be supplied when problem = "multiple outcomes", which should be coded as 0 or 1.

P

Propensity score vector when problem = "multiple outcomes". If not supplied, then study is treated as randomzied trial and the propensity score is estimated as the proportion of 1's in Trt for every subject.

Xlist

A list object that should be supplied when problem = "meta-analysis", with kth element denoting the covariate matrix of study k.

Ylist

When problem = "meta-analysis", Ylist should be a list object with kth element denoting the response vector of study k. When problem = "multiple outcomes", Ylist should be a list object with kth element denoting the kth outcome.

Trtlist

A list object that should be supplied when problem = "meta-analysis", with kth element denoting the treatment vector of study k (coded as 0 or 1).

Plist

A list object that should be supplied when problem = "meta-analysis", with kthe element denoting the propensity score vector of study k. If not supplied, then each study is treated as randomized trial and the corresponding propensity score is estimated as the proportion of 1's in the kth element of Trtlist for all subjects.

typelist

A list object with kth element denoting the type of outcome corresponding to the kth element in Ylist. Each element could be "continuous" or "binary".

penalty

For different rules, the penalty could be "lasso", "GL", "SGL", "fused", "lasso+fused", "GL+fused", "SGL+fused", or "SGL+SL". For single rule, the penalty could only be "lasso". For penalty = "none", use function mpersonalized instead. User should always input penalty and then supply correponding penalty parameters sequence if needed.

lambda1

λ_1 in the framework of different rules. If not supplied, a default sequence will be computed.

lambda2

λ_2 in the framework of different rules. If not supplied, a default sequence will be computed.

tau0

Parameter τ_0 for the "SGL+SL" penalty in the framework of different rules. If not supplied, a default sequence will be computed.

single_rule_lambda

λ_{single} in the framework of single rule.

num_lambda1

If lambda1 is not specified by user, user could still specify the length of the lambda1 sequence. The default length is 10.

num_lambda2

If lambda2 is not specified by user, user could still specify the length of the lambda2 sequence. The default length is 10.

num_tau0

If tau0 is not specified by user, the user can still specify the length of the tau0 sequence. The default length is 11.

min_tau

If tau0 is not specified by user, min_tau specifies the minimum value for τ_0. The largest value for τ_0 will be 1 / min_tau.

num_single_rule_lambda

If single_rule_lambda is not specified, user could still specify the length of the single_rule_lambda sequence. The default length is 50.

alpha

α in the framework of different rules. If not supplied, a default value will be used depending on penalty.

single_rule

A logical value, whether the single treatment framework is used. Deafult is FALSE.

cv_folds

Number of folds needed for cross-validation. Default is 5

admm_control

A list of parameters which user can specify to control the admm algorithm. In admm_control, the following parameters can be supplied: abs.tol, absolute tolerance; rel.tol, relative tolerance; maxit, maximum number of iterations; rho, Lagrangian parameter.

contrast_builder_control

A list of parameters which user can specify to control estimation of contrast function. In contrast_builder_control, the following parameters could be supplied: eff_aug, a logical value whether efficiency augmentation should be implemented; response_model, a character string specify what outcome model to use if eff_aug = TRUE, response_model could be "lasso" or "linear"; contrast_builder_folds, the number of folds used in cross validation when response_model = "lasso".

Value

An S3 object of class "mp_cv", which contains the information of the model with the optimal lambda. It can be supplied to some other functions in mperosnalized package for further analysis or prediction.

penalty_parameter_sequence

A matrix object with each row denoting a configuration of the penalty parameters.

opt_penalty_parameter

Optimal penalty parameter chosen by minimizing the cross validation error.

intercept

The vector of intercepts corresponding to the optimal penalty parameter.

beta

The coefficient matrix corresponding to the optimal penalty parameter.

number_covariates

Number of candidate covariates considered.

number_studies_or_outcomes

Number of studies if problem = "meta-analysis" or number of outcomes if problem = "multiple outcomes".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
set.seed(123)
sim_dat = simulated_dataset(n = 200, problem = "meta-analysis")
Xlist = sim_dat$Xlist; Ylist = sim_dat$Ylist; Trtlist = sim_dat$Trtlist

# fit different rules with group lasso penalty
mp_cvmod_diff = mpersonalized_cv(problem = "meta-analysis",
                                 Xlist = Xlist, Ylist = Ylist, Trtlist = Trtlist,
                                 penalty = "GL", single_rule = FALSE)

mp_cvmod_diff$intercept
mp_cvmod_diff$beta

# fit a single rule with lasso penalty
mp_cvmod_single = mpersonalized_cv(problem = "meta-analysis",
                                   Xlist = Xlist, Ylist = Ylist, Trtlist = Trtlist,
                                   penalty = "lasso", single_rule = TRUE)

mp_cvmod_single$intercept
mp_cvmod_single$beta
set.seed(NULL)

chenshengkuang/mpersonalized documentation built on May 28, 2019, 7:16 p.m.