These functions override the crr function provided in cmprsk to produce more manageable competing risks model results (i.e. include model.frame and formula in output) so that results can leverage functions like broom::tidy the same way other regression function results do.

crr(formula, data, ...)

# S3 method for formula
crr(formula, data, ...)

# S3 method for default
crr(...)

Arguments

formula

formula object with response on the left of a ~ operator and terms on the right. Event variable can have multiple levels for use in competing risks.

data

a data.frame in which to interpret the variables named in the formula

...

Arguments passed on to cmprsk::crr

ftime

vector of failure/censoring times

fstatus

vector with a unique code for each failure type and a separate code for censored observations

cov1

matrix (nobs x ncovs) of fixed covariates (either cov1, cov2, or both are required)

cov2

matrix of covariates that will be multiplied by functions of time; if used, often these covariates would also appear in cov1 to give a prop hazards effect plus a time interaction

tf

functions of time. A function that takes a vector of times as an argument and returns a matrix whose jth column is the value of the time function corresponding to the jth column of cov2 evaluated at the input time vector. At time tk, the model includes the term cov2[,j]*tf(tk)[,j] as a covariate.

cengroup

vector with different values for each group with a distinct censoring distribution (the censoring distribution is estimated separately within these groups). All data in one group, if missing.

failcode

code of fstatus that denotes the failure type of interest

cencode

code of fstatus that denotes censored observations

subset

a logical vector specifying a subset of cases to include in the analysis

na.action

a function specifying the action to take for any cases missing any of ftime, fstatus, cov1, cov2, cengroup, or subset.

gtol

iteration stops when a function of the gradient is < gtol

maxiter

maximum number of iterations in Newton algorithm (0 computes scores and var at init, but performs no iterations)

init

initial values of regression parameters (default=all 0)

variance

If FALSE, then suppresses computation of the variance estimate and residuals

Examples

trial <- na.omit(trial) #original crr covars <- model.matrix(~ age + factor(trt) + factor(grade), trial)[,-1] ftime1 <- trial$ttdeath fstatus1 <- trial$death_cr mod_orig <- crr(ftime=ftime1, fstatus = fstatus1, cov1 = covars) # using new wrapper function, accepts data and formula mod_new <- crr(Surv(ttdeath, death_cr) ~ age + trt + grade, trial)