generated from rstudio/bookdown-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
06-Time-To-Event-Outcomes.Rmd
314 lines (173 loc) · 8.79 KB
/
06-Time-To-Event-Outcomes.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# Time-To-Event Outcomes {#timetoevent}
We will illustrate covariate adjustment for time-to-event outcomes using the simulated MISTIE III dataset. The code to load this data is in the chapter on [Using R](#Load_MISTIE). Here we are interested in whether the minimally invasive surgery procedure improves survival in the first 90 days after randomization.
--------------------------------------------------------------------------------
## Unadjusted Estimators
Before discussing covariate adjustment in time-to-event outcomes, it is worth reviewing unadjusted methods, the assumptions needed for their valid use, and their interpretation.
The Kaplan-Meier (or K-M) estimate of the survival function is one of the most ubiquitous approaches to time-to-event outcomes. The K-M estimator assumes that censoring occurs independent of event time in each treatment arm. This is often violated when baseline covariates associated with event times and dropout [@Diaz2018].
The Logrank test and the Cox Proportional Hazards model are closely related to each other and [the proportional hazards assumption](#hazard_ratio). The Logrank Test provides a valid test of the null hypothesis if censoring is independent of treatment or the event time in each treatment arm [@VanLancker2021]. While its validity does not depend on the proportional hazards (PH) assumption, its power is greatest when the PH assumption is true. When the PH assumption does not hold, weighted logrank tests can improve power by emphasizing different parts of the survival curve [@Lin2017].
The Cox Proportional Hazards (PH) Model provides a valid test of the null hypothesis if the sandwich covariance estimator is used and censoring is either conditionally independent of treatment assignment given the covariates or conditionally independent of the covariates given treatment assignment. As previously mentioned, the [proportional hazards assumption](#hazard_ratio) may not be known to hold a priori, presents difficulties in interpretation when the assumption does not empirically hold, and does not quantify the amount of time a participant can expect to be event free under a particular treatment [@Rudser2012].
The Restricted Mean Survival Time assumes that $\ldots$.
The Survival Probability assumes that $\ldots$.
--------------------------------------------------------------------------------
### Kaplan-Meier Estimator
```{r KM-MISTIE-Survival, echo = FALSE}
library(survival)
library(survminer)
time_to_death_km <-
survfit(
formula = miii_surv ~ arm,
data = sim_miii
)
miii_surv <-
with(sim_miii,
survival::Surv(
time = days_on_study,
event = died_on_study
)
)
ggsurvplot(
fit = time_to_death_km,
conf.int = TRUE,
risk.table = TRUE,
xlab = "Days",
ylab = "Survival probability"
)
```
--------------------------------------------------------------------------------
### Logrank Test
The Logrank test (and the $G^{\rho}$ family of tests) can be performed using the `survival::survdiff` function:
```{r Logrank-MISTIE}
survival::survdiff(
formula =
Surv(time = days_on_study,
event = died_on_study) ~ arm,
data = sim_miii
)
```
--------------------------------------------------------------------------------
### Cox Proportional Hazards Model
The Cox Proportional Hazards model can be fitted using the `survival::coxph` function: the specification of the model is done using a formula object, with a `survival::Surv` object on the left hand side, and the covariates specified on the right hand side. To obtain the robust variance estimate of the coefficients, the `robust` argument should be set to `TRUE`. See `?survival::coxph` for more details, such as handling of tied survival times.
```{r Unadjusted-Cox-MISTIE}
unadjusted_cox <-
survival::coxph(
formula =
Surv(time = days_on_study,
event = died_on_study) ~ arm,
ties = "efron",
robust = TRUE,
data = sim_miii
)
summary(unadjusted_cox)
```
Tests for the proportional hazards assumption using weighted residuals can be obtained using `survival::cox.zph`.
```{r Unadjusted-Cox-PH-Test-MISTIE}
unadjusted_cox_ph_test <-
survival::cox.zph(unadjusted_cox)
print(unadjusted_cox_ph_test)
```
In addition to test statistics, plots can be used to visualize how covariate effects vary by time on study:
```{r Unadjusted-Cox-PH-Plot-MISTIE}
# Plot Proportionality Results
plot(unadjusted_cox_ph_test,
main = "Proportional Hazards Test")
abline(h = 0, col = "red")
```
Here we see that the hazard ratio for treatment arm is negative initially, reflecting lower mortality after randomization in the surgical arm. The magnitude of this effect decreases with time, eventually becoming indistinguishable from zero. This pattern of mortality and time-varying treatment effect is consistent with the fact that most stroke-related mortality occurs in the few weeks following its initial onset, and the intervention is only expected to address mortality related to the initial hemorrhagic stroke. In such a setting, we might expect a violation of the proportional hazards assumption at some point in follow-up, but not know how the treatment effect varies in time.
--------------------------------------------------------------------------------
### Survival Probability
```{r Unadjusted-Survival-Metadata-MISTIE, eval = FALSE}
surv_metadata_unadj <-
adjrct::survrct(
outcome.formula =
Surv(days_on_study, died_on_study) ~ tx,
trt.formula = tx ~ 1,
data = sim_miii,
)
```
```{r Unadjusted-Survival-Probability-MISTIE, eval = FALSE}
surv_prob_unadj <-
adjrct::survprob(
metadata = surv_metadata_unadj,
horizon = 90
)
```
```{r Unadjusted-Survival-Probability-MISTIE-Print, results = 'asis', message = TRUE}
surv_prob_unadj
```
--------------------------------------------------------------------------------
### Restricted Mean Survival Time (RMST)
The `survRM2` package can be used to obtain the RMST in each arm, as well as differences and ratios of the RMST between treatment arms:
```{r Unadjusted-RMST-survRM2-MISTIE}
with(
sim_miii,
survRM2::rmst2(
time = days_on_study,
status = died_on_study,
arm = tx,
tau = 90
)
)
```
This can also be done using the `adjrct` package. Once the "survival metadata" has been produced using the `adjrct::survrct` function, the metadata can be passed to the `adjrct::rmst` function.
```{r Unadjusted-RMST-adjrct-MISTIE, eval = FALSE}
rmst_unadj <-
adjrct::rmst(
metadata = surv_metadata_unadj,
horizon = 90
)
```
```{r Unadjusted-RMST-adjrct-MISTIE-print, results = 'asis', message = TRUE}
rmst_unadj
```
--------------------------------------------------------------------------------
## Event-Driven Trials
--------------------------------------------------------------------------------
## Covariate-Adjusted Estimators
--------------------------------------------------------------------------------
### Kaplan-Meier Estimator
--------------------------------------------------------------------------------
### Survival Probability
Producing covariate-adjusted estimates of the survival metadata follows the same syntax as before with `adjrct::survrct`. The formulas can be used to include terms for the baseline covariates in both the outcome and treatment models:
```{r Adjusted-Survival-Metadata-MISTIE, eval = FALSE}
# Note: this can be time-consuming to compute
surv_metadata_adj <-
adjrct::survrct(
outcome.formula =
Surv(days_on_study, died_on_study) ~
tx + age + male + hx_cvd + hx_hyperlipidemia +
on_anticoagulants + on_antiplatelets + ich_location +
ich_s_volume + ivh_s_volume + gcs_category,
trt.formula =
tx ~
age + male + hx_cvd + hx_hyperlipidemia +
on_anticoagulants + on_antiplatelets + ich_location +
ich_s_volume + ivh_s_volume + gcs_category,
data = sim_miii
)
```
Once the metadata is computed, the syntax to produce the results is identical:
```{r Adjusted-Survival-Probability-MISTIE, eval = FALSE, results = 'asis'}
surv_prob_adj <-
adjrct::survprob(
metadata = surv_metadata_adj,
horizon = 90
)
```
The results can be printed using the `base::print` function:
```{r Adjusted-Survival-Probability-MISTIE-Print, results = 'asis', message = TRUE}
surv_prob_adj
```
--------------------------------------------------------------------------------
### Restricted Mean Survival Time (RMST)
Similar to the survival probability, once the metadata is computed, the syntax to produce the covariate-adjusted RMST is identical:
```{r Adjusted-RMST-adjrct-MISTIE, eval = FALSE}
rmst_adj <-
adjrct::rmst(
metadata = surv_metadata_adj,
horizon = 90
)
```
Similarly, results can be printed using the `base::print` function:
```{r Adjusted-RMST-adjrct-MISTIE-print, results = 'asis', message = TRUE}
rmst_adj
```