glmnetsurv: Fit and perform post fitting procedures to glmnet survival...

View source: R/glmnetpostsurv.R

glmnetsurvR Documentation

Fit and perform post fitting procedures to glmnet survival models

Description

Extends functionality of survival models in glmnet to compute survival curves and other calibrations.

Usage

glmnetsurv(
  formula = formula(data),
  data = sys.parent(),
  family = "cox",
  alpha = 1,
  lambda = NULL,
  s = NULL,
  method = "breslow",
  x = FALSE,
  contrasts.arg = NULL,
  xlevs = NULL,
  na.action = na.omit,
  ...
)

Arguments

formula

Object of class formula describing the model. The response and terms are specified similar to Surv function.

data

optional data frame containing variables specified in the formula.

family

currently, only glmnet "cox" family (survival model) is allowed.

alpha

the elasticnet mixing parameter, see glmnet.

lambda

optional user supplied lambda sequence, see glmnet. It is recommended that you supply a sequence of lambdas.optimal from glmnetsurvcv object.

s

a single value of lambda over which predictions or extractions are made. Ideally, this value should be obtained from glmnetsurvcv if not known. This can be NULL (or not specified) if a single value of lambda is specified, otherwise required if lambda = NULL or if lambda is a vector.

method

for ties handling. Currently, only "breslow" is implemented.

x

logical value. If TRUE, the x matrix is returned in component otherwise NULL.

contrasts.arg

an optional list. See the contrasts.arg of [stats]{model.matrix.default}.

xlevs

a named list of character vectors giving the full set of levels to be assumed for each factor. See [stats]{model.frame}.

na.action

a function which indicates what should happen when the data contain NAs. See [stats]{model.frame}.

...

any of the options in glmnet.

Details

This functions offers a user friendly formular-data interface for fitting survival models using glmnet. Any additional glmnet arguments can be specified in ....

Value

A list of glmnetsurv objects:

fit

fitted glmnet model object

X

model matrix of model terms.

y

Surv object defining the event times and event status.

s

lambda used

See Also

glmnetsurvcv, Surv, glmnet, cv.glmnet

Examples


# 
data(veteran, package="survival")
## Fit unpenalized Cox using glmnet
lam <- 0 # Should fit unpenalized Cox model
gfit1 <- glmnetsurv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, lambda = lam
	, alpha = 1
)
print(gfit1)

# Perform cross-validation
gfit2 <- glmnetsurv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, lambda = NULL
	, alpha = 1
	, s = 0.002
)
plot(gfit2)

CYGUBICKO/glmnetpostsurv documentation built on Sept. 1, 2022, 7:26 p.m.