Learn R Programming

StratifiedMedicine (version 0.1.3)

filter_glmnet: Filter: Elastic Net (glmnet)

Description

Filter variables through elastic net (Zou and Hastie 2005). Default is to regress Y~X (search for prognostic variables). Variables with estimated coefficients of zero (depends on lambda choice; default is lambda.min) are filtered. Usable for continuous, binary, and survival outcomes.

Usage

filter_glmnet(Y, A, X, lambda = "lambda.min", family = "gaussian",
  interaction = FALSE, ...)

Arguments

Y

The outcome variable. Must be numeric or survival (ex; Surv(time,cens) )

A

Treatment variable. (a=1,...A)

X

Covariate space.

lambda

Lambda for elastic net model (default="lambda.min"). Other options include "lambda.1se" and fixed values

family

Outcome type ("gaussian", "binomial", "survival"), default is "gaussian"

interaction

Regress Y~X+A+A*X (interaction between covariates and treatment)? Default is FALSE. If TRUE, variables with zero coefficients (both X and X*A terms) are filtered.

...

Any additional parameters, not currently passed through.

Value

Filter model and variables that remain after filtering.

  • mod - Filtering model

  • filter.vars - Variables that remain after filtering (could be all)

Examples

Run this code
# NOT RUN {
library(StratifiedMedicine)

## Continuous ##
dat_ctns = generate_subgrp_data(family="gaussian")
Y = dat_ctns$Y
X = dat_ctns$X
A = dat_ctns$A

# Default: Regress Y~X (search for prognostic factors) #
mod1 = filter_glmnet(Y, A, X)
mod2 = filter_glmnet(Y, A, X, lambda = "lambda.min") # same as default
mod3 = filter_glmnet(Y, A, X, lambda = "lambda.1se")
mod1$filter.vars
mod2$filter.vars
mod3$filter.vars

# Interaction=TRUE; Regress Y~X+A+X*A (search for prognostic and/or predictive) #
mod4 = filter_glmnet(Y, A, X, interaction=TRUE)
mod4$filter.vars
# }

Run the code above in your browser using DataLab