Skip to contents

Performs k-fold cross validation for a penalized stratified cox model over a grid of values of regularization parameter lambda.

Usage

cv.strat_cox(
  data,
  Event.char,
  Z.char,
  Time.char,
  prov.char,
  group = 1:length(Z.char),
  se = c("quick", "bootstrap"),
  ...,
  nfolds = 10,
  seed,
  fold,
  trace.cv = FALSE
)

Arguments

data

an dataframe or list object that contains the variables in the model.

Event.char

name of the event indicator in data as a character string. Event indicator should be a binary variable with 1 indicating that the event has occurred and 0 indicating (right) censoring.

Z.char

names of covariates in data as vector of character strings.

Time.char

name of the follow up time in data as a character string.

prov.char

name of provider IDs variable in data as a character string. (can be seen as "stratum")

group

a vector describing the grouping of the coefficients. If there are coefficients to be included in the model without being penalized, assign them to group 0 (or "0").

...

extra arguments to be passed to function.

nfolds

the number of cross-validation folds. Default is 10.

seed

the seed of the random number generator in order to obtain reproducible results.

fold

a vector that specifies the fold that observations belongs to. By default the observations are randomly assigned.

trace.cv

cv.strat_cox will provide user with the progress of cross validation if trace.cv = TRUE. Default is FALSE.

Value

An object with S3 class cv.strat_cox.

cve

the error for each value of lambda, averaged across the cross-validation folds.

cvse

the estimated standard error associated with each value of for cve.

lambda

the sequence of regularization parameter values along which the cross-validation error was calculated.

fit

the fitted strat_cox object for the whole data.

fold

the fold assignments for cross-validation for each observation

min

the index of lambda corresponding to lambda.min.

lambda.min

the value of lambda with the minimum cross-validation error.

References

K. He, J. Kalbfleisch, Y. Li, and et al. (2013) Evaluating hospital readmission rates in dialysis facilities; adjusting for hospital effects. Lifetime Data Analysis, 19: 490-512.

Examples

data(ContTime)
data <- ContTime$data
Event.char <- ContTime$Event.char
prov.char <- ContTime$prov.char
Z.char <- ContTime$Z.char
Time.char <- ContTime$Time.char
cv.fit <- cv.strat_cox(data, Event.char, Z.char, Time.char, prov.char, group = c(1, 2, 2, 3, 3), nfolds = 10, se = "quick")
# the best lambda using cross validation
cv.fit$lambda.min
#> [1] 0.004862236