lasso_selection: LASSO selection for survival and GLM outcomes

View source: R/get_FSdata_helpers.R

lasso_selectionR Documentation

LASSO selection for survival and GLM outcomes

Description

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).

Usage

lasso_selection(
  df,
  confounders.name,
  outcome.name,
  event.name,
  seedit = 8316951,
  outcome_type = "survival",
  offset.name = NULL
)

Arguments

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 "survival" (default), "binary", "continuous", or "count".

offset.name

Character or NULL. Name of the follow-up time column for rate-based measures (IRR, IRD).

Value

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.

Examples


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")


forestsearch documentation built on Nov. 15, 2026, 9:06 a.m.