You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the **survival** (base R) package the log-rank and Cox estimation procedures apply (by default) a correction to "fix" roundoff errors. These are implemented with the *timefix* option (by default *timefix = TRUE*) via the *aeqSurv* function.
34
-
However in the **simtrial** package (and also **Hmisc**) such a correction is not implemented; Consequently, there can be discrepancies between **simtrial** and base R *survival* (*survdiff*, *coxph*, and *survfit*).
23
+
In the survival (base R) package, the log-rank and Cox estimation procedures
24
+
apply (by default) a correction to "fix" roundoff errors.
25
+
These are implemented with the `timefix` option (by default `timefix = TRUE`)
26
+
via the `aeqSurv()` function.
27
+
However, in the simtrial package, (and also Hmisc), such a correction is not
28
+
implemented; Consequently, there can be discrepancies between simtrial and
29
+
base R survival (`survdiff()`, `coxph()`, and `survfit()`).
35
30
36
-
For details on the *aeqSurv* function see [Therneau, 2016](https://cran.r-project.org/web/packages/survival/vignettes/tiedtimes.pdf) and [R documentation, version 3.803](https://www.rdocumentation.org/packages/survival/versions/3.8-3/topics/aeqSurv)
31
+
For details on the `aeqSurv()` function, see [Therneau,
32
+
2016](https://cran.r-project.org/package=survival/vignettes/tiedtimes.pdf) and
33
+
the `?aeqSurv` function documentation.
37
34
38
-
In the following we describe a simulation scenario where a discrepancy is generated and illustrate how discrepancies can be resolved (if desired) by pre-processing survival times with *aeqSurv* and thus replicating *survdiff* and *coxph* default calculations.
35
+
In the following, we describe a simulation scenario where a discrepancy is
36
+
generated and illustrate how discrepancies can be resolved (if desired) by
37
+
pre-processing survival times with `aeqSurv()` and thus replicating `survdiff()`
38
+
and `coxph()` default calculations.
39
39
40
-
In the simulated dataset two observations are generated:
41
-
42
-
- Observation $i=464$ with survival time $Y=0.306132722582$
43
-
- Observation $i=516$ with survival time $Y=0.306132604679$
44
-
- Per "aeqSurv" these times are tied and set to $Y=0.306132604679$
45
-
- The log-rank and Cox estimates can therefore differ between other approaches without the "timefix" correction
40
+
In the simulated dataset, two observations are generated:
46
41
42
+
- Observation $i=464$ with survival time $Y=0.306132722582$.
43
+
- Observation $i=516$ with survival time $Y=0.306132604679$.
44
+
- Per `aeqSurv()`, these times are tied and set to $Y=0.306132604679$.
45
+
- The log-rank and Cox estimates can therefore differ between other approaches
46
+
without the "timefix" correction.
47
47
48
48
## Scenario definitions
49
49
50
-
We define various true data generating model scenarios and convert for use in **gsDesign2**. Here we are using a single scenario where discrepancies were found. This is just for illustration to inform the user of **simtrial** that discrepancies can occur and how to resolve via *aeqSurv*, if desired.
51
-
50
+
We define various true data generating model scenarios and convert for use in
51
+
gsDesign2. Here, we are using a single scenario where discrepancies were found.
52
+
This is just for illustration to inform the user of simtrial that discrepancies
53
+
can occur and how to resolve via `aeqSurv()`, if desired.
Simulated dataset with discrepancy between logrank test of *wlr* (**simtrial**) and *survdiff* (also compare to score test of *coxph*[same as survdiff with default *timefix=TRUE*])
152
+
Simulated dataset with discrepancy between logrank test of `simtrial::wlr()`
153
+
and `survdiff()` (also compare to score test of `coxph()`[same as `survdiff()`
cat("Cox Breslow and Efron hr (tte2, timefix=FALSE):",c(cox_breslow[1],cox_efron[1]),"\n")
246
250
```
247
251
248
-
**So here there is a difference between tte and tte2 times, but there is not an impact of ties for Cox between *breslow* and *efron* because the ties (single tie in tte2) are in separate arms**.
249
-
250
-
Lastly, artificially change treatment so that two observations are tied within the same treatment arm which generates difference between *breslow* and *efron* options for ties:
252
+
**So here there is a difference between `tte` and `tte2` times, but there is
253
+
not an impact of ties for Cox between `"breslow"` and `"efron"` because the ties
254
+
(single tie in `tte2`) are in separate arms**.
251
255
256
+
Lastly, artificially change treatment so that two observations are tied within
257
+
the same treatment arm which generates difference between `"breslow"` and
258
+
`"efron"` options for `ties`:
252
259
253
260
```{r}
254
-
# Create tie within treatment arm by changing treatment
261
+
# Create tie within treatment arm by changing treatment
0 commit comments