-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmprsk2.Rmd
115 lines (80 loc) · 3.31 KB
/
cmprsk2.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{cmprsk2 intro}
-->
## Subdistribution Analysis of Competing Risks
* [intro](#intro)
* [design](#design)
* [examples](#examples)
* [install](#install)
```{r, message=FALSE}
library('cmprsk2')
library('htmlTable')
```
## intro
Extensions to the **`cmprsk`** package:
1. estimation, testing, and regression modeling of subdistribution functions in competing risks, as described in Gray (1988);
1. A class of K-sample tests for comparing the cumulative incidence of a competing risk, Ann. Stat. 16:1141-1154, and Fine JP and Gray RJ (1999); and
1. A proportional hazards model for the subdistribution of a competing risk, JASA, 94:496-509.
## design
The two main package functions, `cuminc2` and `crr2`, provide a convenient formula-interface to `cmprsk::cuminc` and `cmprsk::crr` to users who are familiar with using survival objects in the **`survival`** package.
The syntax for creating survival objects is
$$Surv(time, status) \sim rhs$$
Similarly, the syntax for creating **`cmprsk`** objects is
$$Surv(time, status(censor) == event) \sim rhs$$
where `status` is a categorical variable with censoring indicators, usually "0", "Censor", "Censored", etc., and two or more unique event indicators for each competing risk. `event` in the formula will be one of the event indicators found in `status` and will be considered the primary event of interest.
## examples
### cumulative incidence
Note in the formula that it is not necessary to specify the event of interest for `cuminc2`.
```{r}
ci <- cuminc2(Surv(futime, event(censored)) ~ sex, transplant)
summary(ci)
cmprsk::timepoints(ci$cuminc, times = 0:4 * 500)
cmprsk2::timepoints2(ci)
cmprsk2::timepoints2(
ci, sd = TRUE, html = TRUE,
htmlArgs = list(caption = 'Table 1: Timepoints.')
)
plot(ci)
ci <- cuminc2(Surv(futime, event(censored)) ~ abo, transplant)
cuminc_pairs(ci)$p.value
plot(ci, split = 'event')
```
### competing risks regression
While it is necessary to specify the event of interest in the `crr2` formula, this will be the _primary_ event of interest. That is, by default models are fit for all competing events, but the primary event model will be listed first.
Using `crr2(..., which = event)` will only fit model(s) for `event`.
```{r}
cr <- crr2(Surv(futime, event(censored) == death) ~ sex, transplant)
summary(cr)
cr <- crr2(Surv(futime, event(censored) == death) ~ sex + abo, transplant)
summary(cr, n = TRUE, ref = TRUE)
cr <- crr2(Surv(futime, event(censored) == ltx) ~ sex + abo, transplant,
cox = Surv(futime, event == 'death') ~ sex + abo)
summary(
cr, html = TRUE, n = TRUE, ref = TRUE,
htmlArgs = list(
caption = 'Table 1: Competing risks.',
rnames = with(transplant, c(levels(sex), levels(abo)))
)
)
cr <- crr2(Surv(futime, event(censored) == ltx) ~ sex + abo, transplant,
which = 'ltx')
summary(
cr, html = TRUE, n = TRUE,
htmlArgs = list(
caption = 'Table 1: Competing risks.',
tfoot = '<font size=1>Reference groups: Sex, male; blood type, A.</font>',
rgroup = c('Sex', 'Blood type'),
rnames = c('Female', paste('Type:', c('B', 'AB', 'O')))
)
)
```
## install
```{r, eval=FALSE}
# install.packages('devtools')
devtools::install_github('raredd/cmprsk2', build_vignettes = TRUE)
```
## session
```{r, eval=TRUE}
utils::sessionInfo()
```