survdiffr: Bootstrap survival quantiles for recurrent event data

View source: R/survdiffr.R

survdiffrR Documentation

Bootstrap survival quantiles for recurrent event data

Description

Obtains bootstrap replicates of a quantile (e.g. the median) of the survival time for each group of subjects. Confidence intervals of the replicates can be computed with boot::boot.ci().

Usage

survdiffr(
  formula,
  data,
  q,
  B = 500,
  boot.F = "WC",
  boot.G = "none",
  seed = NULL,
  ...
)

Arguments

formula

a formula object with a Survr() object as the response on the left of the ~ operator and a grouping term on the right.

data

a data frame in which to interpret the variables named in the formula.

q

quantile of the survival function whose time is bootstrapped.

B

number of bootstrap samples.

boot.F

a character string specifying the bootstrap procedure: "PSH" or "WC" (nonparametric) or "semiparametric". The default is "WC". Only the first letters are required, e.g. "P", "W", "se".

boot.G

a character string specifying whether the censoring times are also resampled from their empirical distribution: "none" (default) or "empirical". Only the first letters are required.

seed

optional random seed for the bootstrap resampling (passed to set.seed()). If NULL (default) the current state of the random number generator is used.

...

additional arguments passed to the estimator used for the observed (non-bootstrap) quantile.

Details

Three resampling schemes are available through boot.F: nonparametric resampling of gap times from the Peña-Strawderman-Hollander ("PSH") or the Wang-Chang ("WC") estimates of the inter-occurrence time distribution, and semiparametric resampling under the fitted gamma frailty model ("semiparametric"). With boot.G = "empirical" the per-subject censoring times are additionally resampled from their empirical distribution.

All resampling uses R's random number generator, so results are reproducible with set.seed() or the seed argument. The re-estimation of the survival curve on each replicate can run in parallel, see survrecThreads(). Some procedures (notably the semiparametric one, which refits the frailty model on every replicate) can be slow.

Value

An object of class boot (or a named list with one per group) whose t0 is the observed quantile and t the bootstrap replicates. A replicate is -1 when the survival estimate does not fall below q, and NA when the resampled data had no events. For the semiparametric procedure the component alpha contains the frailty parameter estimated on each replicate.

References

González, J.R. and Peña, E.A. (2003). Bootstrapping median survival with recurrent event data. IX Conferencia Española de Biometría.

See Also

survfitr(), boot::boot.ci(), survrecThreads()

Examples

data(colon)

# compare the median survival time between the three Dukes stages
fit <- survdiffr(Survr(hc, time, event) ~ as.factor(dukes),
  data = colon, q = 0.5, seed = 1
)
boot::boot.ci(fit$"1", type = c("norm", "basic", "perc"))
boot::boot.ci(fit$"2", type = c("norm", "basic", "perc"))
boot::boot.ci(fit$"3", type = c("norm", "basic", "perc"))

# 75th quantile with percentile confidence intervals
fit <- survdiffr(Survr(hc, time, event) ~ as.factor(dukes),
  data = colon, q = 0.75, seed = 1
)
quantile(fit$"1"$t, c(0.025, 0.975))

# resampling from the PSH estimate instead
fit <- survdiffr(Survr(hc, time, event) ~ as.factor(dukes),
  data = colon, q = 0.5, boot.F = "PSH", seed = 1
)

survrec documentation built on Sept. 22, 2026, 9:07 a.m.