Main function for fitting a penalized stratified cox model.
Usage
Strat.cox(
data,
Event.char,
Z.char,
Time.char,
prov.char,
group = 1:length(Z.char),
group.multiplier,
standardize = T,
lambda,
nlambda = 100,
lambda.min.ratio = 0.001,
lambda.early.stop = FALSE,
nvar.max = p,
group.max = length(unique(group)),
stop.loss.ratio = 0.001,
tol = 1e-04,
max.each.iter = 10000,
max.total.iter = (max.each.iter * nlambda),
actSet = TRUE,
actIter = max.each.iter,
actGroupNum = sum(unique(group) != 0),
actSetRemove = F,
returnX = FALSE,
trace.lambda = FALSE,
...
)
Arguments
- data
an
dataframe
orlist
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 stratum indicator in
data
as a character string. If "prov.char" is not specified, all observations are are considered to be from the same 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").
- group.multiplier
A vector of values representing multiplicative factors by which each covariate's penalty is to be multiplied. Default is a vector of 1's.
- standardize
logical flag for x variable standardization, prior to fitting the model sequence. The coefficients are always returned on the original scale. Default is
standardize=TRUE
.- lambda
a user supplied lambda sequence. Typical usage is to have the program compute its own lambda sequence based on
nlambda
andlambda.min.ratio
.- nlambda
the number of lambda values. Default is 100.
- lambda.min.ratio
the fraction of the smallest value for lambda with
lambda.max
(smallest lambda for which all coefficients are zero) on log scale. Default is 1e-03.- lambda.early.stop
whether the program stop before running the entire sequence of lambda. Early stop based on the ratio of deviance for models under two successive lambda. Default is
FALSE
.- nvar.max
number of maximum selected variables. Default is the number of all covariates.
- group.max
number of maximum selected groups. Default is the number of all groups.
- stop.loss.ratio
if
lambda.early.stop = TRUE
, the ratio of loss for early stopping. Default is 1e-3.- tol
convergence threshold. For each lambda, the program will stop if the maximum change of covariate coefficient is smaller than
tol
. Default is 1e-4.- max.each.iter
maximum number of iterations for each lambda. Default is 1e4.
- max.total.iter
maximum number of iterations for entire path. Default is
max.each.iter
*nlambda
.- actSet
whether to use the active method for variable selection. Default is TRUE.
- actIter
if
actSet = TRUE
, the maximum number of iterations for a new updated active set. Default ismax.each.iter
(i.e. we will update the current active set until convergence ).- actGroupNum
if
actSet = TRUE
, the maximum number of variables that can be selected into the new active set for each time when the active set is updated. Default is number of groups.- actSetRemove
if
actSet = TRUE
, whether we remove the zero coefficients from the current active set. Default is FALSE.- returnX
whether return the standardized design matrix. Default is FALSE.
- trace.lambda
whether display the progress for fitting the entire path. Default is FALSE.
- ...
extra arguments to be passed to function.
Value
An object with S3 class strat_cox
.
- beta
the fitted matrix of covariate coefficients. The number of rows is equal to the number of coefficients, and the number of columns is equal to nlambda.
- group
a vector describing the grouping of the coefficients.
- lambda
the sequence of
lambda
values in the path.- loss
the likelihood of the fitted model at each value of
lambda
.- linear.predictors
the linear predictors of the fitted model at each value of
lambda
.- df
the estimates of effective number of selected variables all the points along the regularization path.
- iter
the number of iterations until convergence at each value of
lambda
.
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
fit <- Strat.cox(data, Event.char, Z.char, Time.char, prov.char, group = c(1, 2, 2, 3, 3))
fit$beta[, 1:5]
#> 0.0394 0.0368 0.0343 0.032 0.0298
#> Z1 0 -0.01983922 -0.0390155 -0.05686517 -0.07358008
#> Z2 0 0.00000000 0.0000000 0.00000000 0.00000000
#> Z3 0 0.00000000 0.0000000 0.00000000 0.00000000
#> Z4 0 0.00000000 0.0000000 0.00000000 0.00000000
#> Z5 0 0.00000000 0.0000000 0.00000000 0.00000000