View source: R/get_FSdata_helpers.R
| lasso_selection | R Documentation |
Performs LASSO variable selection with glmnet: a Cox model for
outcome_type = "survival", and a logistic (binomial), linear
(gaussian) or Poisson model for binary, continuous and count outcomes
(Poisson also for a binary outcome when offset.name is given).
lasso_selection(
df,
confounders.name,
outcome.name,
event.name,
seedit = 8316951,
outcome_type = "survival",
offset.name = NULL
)
df |
Data frame. |
confounders.name |
Character vector of confounder names. |
outcome.name |
Character. Name of outcome variable. |
event.name |
Character. Name of event indicator variable. |
seedit |
Integer. Random seed. |
outcome_type |
Character. One of |
offset.name |
Character or |
List with selected, omitted variables, coefficients, lambda, and fits.
selected and omitted contain confounders only; the
"(Intercept)" of a GLM fit is in neither, but is kept in
coefficients.
library(survival)
df <- survival::gbsg
df$grade3 <- as.integer(df$grade == "3")
lasso_selection(df,
confounders.name = c("age", "meno", "size", "grade3", "nodes", "pgr", "er"),
outcome.name = "rfstime", event.name = "status")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.