Plant an illness-death process onto the arms and covariates of data:
recurrence, death without recurrence, and death after recurrence, each with
piecewise-constant baseline rates, arm effects that may fade after a time
and may depend on a covariate, and covariate effects. Administrative
censoring follows. The true value of each estimand is computed twice, by
exact integration and by Monte Carlo, and the two must agree.
Arguments
- data
A data frame holding the arm and the covariates named in the effects.
- arm
Name of the arm column.
- cuts
Increasing interior cut points of the baseline rates.
- rates
A list with numeric vectors
recurrence,deathanddeath_after, each of lengthlength(cuts) + 1: the reference-arm rates at the mean covariates.- arm_effects
A list (per transition, any subset) of named numeric log hazard ratios, one per non-reference arm level.
- covariate_effects
A list (per transition) of named numeric log hazard ratios per unit of each covariate column.
- arm_modifiers
A list (per transition) of named numeric changes in the arm log hazard ratio per unit of each covariate.
- fade_time
Time after which arm effects are multiplied by
fade_factor(NULLfor no fading).- fade_factor
Multiplier of the arm effects after
fade_time.- censor_time
Administrative censoring time: a single time or one per row of
data.- times
Landmark times for
os_survivalandrec_cif.- tau
Horizon for
os_rmstandrec_time_lost.- reference
Reference arm level (default: the first level).
- seed
Integer seed. The caller's random-number state is restored.
- n_mc
Monte Carlo draws per arm for the second route. Peak memory grows in proportion: about 36 MB per 100,000 draws in the two-arm example below.
Value
A sest_simulation list: data (the input with efs_time,
efs_event (a factor: censor, recurrence, death), os_time,
os_status), truth (data frame of estimand, time, arm,
reference (NA for arm rows), exact, mc, mc_se, z), and the
settings.
Details
Model. States are 0 (alive, no recurrence), 1 (recurrence) and 2
(dead). For subject \(i\) in arm \(a\), transition \(q\) (recurrence
0 to 1, death 0 to 2, death_after 1 to 2) has hazard
$$h_q(t) = \lambda_{qk}\exp\{\gamma_q^\top (z_i - \bar z) +
f(t)\,(\beta_{qa} + \delta_q^\top (z_i - \bar z))\}$$
for \(t\) in interval \(k\), where \(\lambda_{qk}\) are the rates,
\(\gamma_q\) the covariate_effects, \(\beta_{qa}\) the
arm_effects (zero for the reference arm), \(\delta_q\) the
arm_modifiers (applied to every non-reference arm), and
\(f(t) = 1\) before fade_time and fade_factor after it. Covariates are
centred at their sample means. Time is calendar time since randomisation
(a Markov model).
Estimands, each arm standardised over the rows of data (the effect of
assigning everyone that arm), and each non-reference arm minus the
reference: os_survival (overall survival at each of times), os_rmst
(restricted mean survival to tau), rec_cif (probability of recurrence
by each of times, death without recurrence competing) and
rec_time_lost (time lost to recurrence by tau, the area under
rec_cif).
Two routes. The exact route evolves the state probabilities through
each constant-rate piece in closed form and integrates them in closed form.
The Monte Carlo route draws n_mc subjects (rows of data sampled with
replacement, the same draws and random numbers for every arm), simulates
their uncensored histories, and averages. A route disagreement beyond five
Monte Carlo standard errors is a refusal.
Examples
set.seed(1)
d <- data.frame(arm = factor(rep(c("ctl", "trt"), 100)),
age = stats::rnorm(200, 60, 10))
sim <- sest_simulate(d, "arm", cuts = 2,
rates = list(recurrence = c(0.15, 0.05), death = c(0.02, 0.03),
death_after = c(0.4, 0.3)),
arm_effects = list(recurrence = c(trt = -0.4)),
covariate_effects = list(death = c(age = 0.03)),
censor_time = 8, times = 5, tau = 5, seed = 1L, n_mc = 1e5)
sim$truth
#> estimand time arm reference exact mc mc_se
#> 1 os_survival 5 ctl <NA> 0.68822356 0.6880900 0.0014650061
#> 2 os_rmst 5 ctl <NA> 4.24420982 4.2444992 0.0042613017
#> 3 rec_cif 5 ctl <NA> 0.34877005 0.3499000 0.0015082184
#> 4 rec_time_lost 5 ctl <NA> 1.17866892 1.1856969 0.0056533609
#> 5 os_survival 5 trt <NA> 0.74234458 0.7420600 0.0013835059
#> 6 os_rmst 5 trt <NA> 4.38267339 4.3827940 0.0039561958
#> 7 rec_cif 5 trt <NA> 0.25027739 0.2518100 0.0013726019
#> 8 rec_time_lost 5 trt <NA> 0.83248924 0.8384671 0.0050243747
#> 9 os_survival 5 trt ctl 0.05412103 0.0539700 0.0007716076
#> 10 os_rmst 5 trt ctl 0.13846357 0.1382948 0.0013948920
#> 11 rec_cif 5 trt ctl -0.09849265 -0.0980900 0.0009405809
#> 12 rec_time_lost 5 trt ctl -0.34617969 -0.3472298 0.0022823774
#> z
#> 1 -0.09116347
#> 2 0.06790484
#> 3 0.74919591
#> 4 1.24314597
#> 5 -0.20569697
#> 6 0.03049309
#> 7 1.11656955
#> 8 1.18976877
#> 9 -0.19573154
#> 10 -0.12096015
#> 11 0.42809131
#> 12 -0.46009425
