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



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.


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


Arguments passed on to cmprsk::crr


vector of failure/censoring times


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


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


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


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.


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.


code of fstatus that denotes the failure type of interest


code of fstatus that denotes censored observations


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


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


iteration stops when a function of the gradient is < gtol


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


initial values of regression parameters (default=all 0)


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


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)