Skip to contents

Turn draws of interval log-hazards and covariate effects (for example, posterior draws from a Poisson fit to sest_split() output) into draws of each arm's standardised survival at times and RMST to tau, and of their differences. Given a second set of draws for a competing cause, it returns the cumulative incidence of the first cause at times and the time lost to it up to tau instead.

Usage

sest_from_hazard_draws(
  draws,
  cuts,
  formula,
  data,
  arm,
  times = NULL,
  tau = NULL,
  baseline = NULL,
  draws_competing = NULL,
  reference = NULL,
  conf_level = 0.95
)

Arguments

draws

A matrix or data frame of draws, one row per draw.

cuts

The interior cut points used to split the data.

formula

A formula, e.g. ~ arm + age, for the covariate design; the left-hand side of a two-sided formula is ignored. Its model-matrix columns (without the intercept) must be columns of draws.

data

The sample to standardise over.

arm

Name of the arm column in data.

times

Numeric times for survival or cumulative incidence.

tau

Horizon for the RMST or the time lost.

baseline

Names of the interval log-hazard columns in draws, in interval order. The default takes the columns whose names start with "interval".

draws_competing

Optional draws for the competing cause, with the same columns.

reference

Reference arm level (default: the first level).

conf_level

Probability of the equal-tailed interval.

Value

A sest_contrast (see sest_contrast()) with interval = "posterior", plus draws_arms and draws_contrasts (matrices, one row per draw, one column per row of arms and contrasts).

Details

For draw \(b\), row \(i\) assigned arm \(a\), and interval \(k\), the hazard is \(h_{ik} = \exp(\alpha_{bk} + x_i(a)^\top\beta_b)\). Survival is \(\exp(-H(t))\) with \(H\) piecewise linear, and the RMST and time lost are integrated in closed form within each interval. Every quantity is averaged over the rows of data (standardisation), so each draw gives one value per arm; the summary is the draw mean, the draw standard deviation, and the equal-tailed interval.

With draws_competing, the cause-1 cumulative incidence over an interval starting at \(s\) is \(F(s) + S(s)\, h_1/h\, (1 - e^{-h u})\), with \(h = h_1 + h_2\), and the time lost integrates it. Rows of the two draw sets are paired.

See also

sest_split().

Other piecewise-exponential: sest_split()

Examples

v <- survival::veteran
sp <- sest_split(survival::Surv(time, status) ~ trt + karno, v,
                    cuts = c(30, 90, 180))
g <- stats::glm(event ~ 0 + interval + trt + karno + offset(log_exposure),
                family = stats::poisson(), data = sp)
# Draws from the large-sample normal approximation stand in for a posterior.
set.seed(1)
dr <- matrix(stats::rnorm(200 * length(stats::coef(g))), 200) %*%
  chol(stats::vcov(g))
dr <- sweep(dr, 2, stats::coef(g), `+`)
colnames(dr) <- names(stats::coef(g))
sest_from_hazard_draws(dr, cuts = c(30, 90, 180), ~ trt + karno, v,
                          arm = "trt", times = 180, tau = 365)
#> <sest_contrast> piecewise_exponential, standardised; interval: posterior
#>   by arm:
#>  estimand time arm estimate       se conf_low conf_high
#>  survival  180   1   0.2311  0.03996   0.1514    0.3044
#>      rmst  365   1 118.7152 11.61926  96.5064  140.4927
#>  survival  180   2   0.1967  0.03910   0.1197    0.2793
#>      rmst  365   2 107.1183 11.18678  85.5651  129.5566
#> 
#>   contrasts against the reference arm:
#>  estimand time arm reference  estimate      se conf_low conf_high
#>  survival  180   2         1  -0.03432  0.0447   -0.106   0.05472
#>      rmst  365   2         1 -11.59697 15.0638  -36.668  18.42320