crr2 | R Documentation |
Regression modeling of subdistribution functions in competing risks.
crr2(
formula,
data,
which = NULL,
cox = FALSE,
variance = TRUE,
cengroup = NULL,
failcode = NULL,
cencode = NULL,
cov2 = NULL,
tf = NULL,
gtol = 1e-06,
maxiter = 10,
init = NULL
)
formula |
a |
data |
a data frame in which to interpret the variables named in
|
which |
optional character string giving the desired outcome of
interest (i.e., one of the unique values of the |
cox |
logical; if alternatively, a formula to be passed to |
variance |
logical; if |
cengroup , failcode , cencode , cov2 |
additional arguments passed to
|
tf |
a function which takes a vector of times and returns a matrix to
be multiplied by |
gtol , maxiter , init |
(optional) additional arguments passed to
|
A list of crr
objects with some additional components:
coxph |
a |
nuftime |
a vector with the number of times each unique
failure time, |
n.missing |
the number of observations removed due to missingness |
attr(, "model.matrix") |
the |
attr(, "model.frame") |
the |
crr
; summary.crr2
;
print.crr2
; finegray2
;
finegray
; coxph
## 'formula' as one would pass to survival::coxph with additional
## indications for the censoring and failure codes
tp <- within(transplant, {
event_ind <- as.integer(event) - 1L
year <- NULL
})
## these are equivalent ways to call 'crr2'
crr2(Surv(futime, event_ind(0) == 1) ~ age + sex + abo, tp)
crr2(Surv(futime, event_ind(0) %in% 1) ~ age + sex + abo, tp)
crr2(Surv(futime, event(censored) == death) ~ age + sex + abo, tp)
## variables can be created or altered as usual
crr2(Surv(futime, event(censored) %in% death) ~ cut(age, 3), tp)
crr2(Surv(futime, event(censored) %in% death) ~ age + I(age ^ 2), tp)
crr2(Surv(futime, event(censored) %in% death) ~ relevel(abo, 'O'), tp)
form <- Surv(futime, event(censored) == death) ~ age + sex + abo
crr2(form, tp[tp$age > 55, ], cox = TRUE, variance = FALSE, which = 'death')
## use the summary method to compare models easily
crrs <- crr2(form, data = transplant,
cox = Surv(futime, event == 'death') ~ age + sex + abo)
summary(crrs)
library('htmlTable')
summary(crrs, html = TRUE, n = TRUE)
## use the call from a crr2 object to run cmprsk::crr
cl <- crr2(Surv(futime, event(censored) == death) ~ age + sex + abo,
na.omit(transplant))
cl[[1]]
cl[[1]]$call$cov2 <- NULL
eval(cl[[1]]$call)
## covariates that are functions of time are identified by tf()
crr2(Surv(futime, event(censored) == death) ~ factor(sex) + tf(age),
data = transplant, tf = function(uft) cbind(uft, uft ^ 2))
## same as above but using the cov2 option
crr2(Surv(futime, event(censored) == death) ~ factor(sex) + tf(age),
cov2 = na.omit(cbind(transplant$age, transplant$age)),
data = transplant, tf = function(uft) cbind(uft, uft ^ 2))
## example from cmprsk::crr
# simulated data to test
set.seed(10)
ftime <- rexp(200)
fstatus <- sample(0:2, 200, replace = TRUE)
cov <- matrix(runif(600), 200, dimnames = list(NULL, c('x1', 'x2', 'x3')))
dat <- data.frame(ftime = ftime, fstatus = fstatus, cov)
## cmprsk::crr
(z1 <- crr(ftime, fstatus, cov, failcode = 1, cencode = 0))
## cmprsk2::crr2
(z2 <- crr2(Surv(ftime, fstatus(0) == 1) ~ ., dat))
summary(z1)
summary(z2)
summary(z2[[1]])
z1$call <- z2[[1]]$call <- NULL
all.equal(z1[names(z1)], z2[[1]][names(z1)])
# [1] TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.