
Split follow-up into intervals for a piecewise-exponential Poisson fit
Source:R/hazard_draws.R
sest_split.RdCut each subject's follow-up at cuts and return one row per subject and
interval entered, with the exposure (time at risk in the interval) and the
event indicator. A Poisson model for event with offset log_exposure and
one rate per interval is then the piecewise-exponential survival model.
Value
A data frame with the covariate columns of the right-hand side and
.id (the row number in data; rows with a missing value are
dropped), interval (a factor labelled "(a,b]"), start, stop,
exposure, log_exposure and event.
Details
Intervals are \((c_{k-1}, c_k]\) with \(c_0 = 0\) and a last interval \((c_K, \infty)\). A subject with time \(T\) and status \(\delta\) enters every interval with \(c_{k-1} < T\); its exposure there is \(\min(T, c_k) - c_{k-1}\), and the event is counted in the interval that contains \(T\) when \(\delta = 1\).
See also
Other piecewise-exponential:
sest_from_hazard_draws()
Examples
sp <- sest_split(survival::Surv(time, status) ~ trt + karno,
survival::veteran, cuts = c(30, 90, 180))
head(sp)
#> .id trt karno interval start stop exposure log_exposure event
#> 1 1 1 60 (0,30] 0 30 30 3.401197 0
#> 2 1 1 60 (30,90] 30 72 42 3.737670 1
#> 3 2 1 70 (0,30] 0 30 30 3.401197 0
#> 4 2 1 70 (30,90] 30 90 60 4.094345 0
#> 5 2 1 70 (90,180] 90 180 90 4.499810 0
#> 6 2 1 70 (180,Inf] 180 411 231 5.442418 1
stats::glm(event ~ 0 + interval + trt + karno + offset(log_exposure),
family = stats::poisson(), data = sp)
#>
#> Call: stats::glm(formula = event ~ 0 + interval + trt + karno + offset(log_exposure),
#> family = stats::poisson(), data = sp)
#>
#> Coefficients:
#> interval(0,30] interval(30,90] interval(90,180] interval(180,Inf]
#> -2.82814 -3.06026 -2.78924 -3.21943
#> trt karno
#> 0.14267 -0.03324
#>
#> Degrees of Freedom: 320 Total (i.e. Null); 314 Residual
#> Null Deviance: 32250
#> Residual Deviance: 367.7 AIC: 635.7