Skip to contents

Estimate, for each arm, the survival probability at times and the restricted mean survival time (RMST) to tau, and their differences from a reference arm. Model-based fits are standardised over the sample; a Kaplan-Meier fit gives the unadjusted contrast.

Usage

sest_contrast(
  fit,
  data,
  arm,
  times = NULL,
  tau = NULL,
  reference = NULL,
  interval = NULL,
  n_boot = 200L,
  seed = 1L,
  conf_level = 0.95
)

Arguments

fit

A sest_fit of kind "cox", "parametric", "spline", "cure" or "nonparametric" (method = "km").

data

The data frame the fit was made on: the sample to standardise over, and the source of the Kaplan-Meier curves. Data whose complete rows differ from the fit's in number or in events are refused.

arm

Name of the arm column in data (a factor, character or 0/1 column). For a model-based fit it must be a variable of the model.

times

Numeric landmark times for the survival contrast.

tau

Single horizon for the RMST contrast.

reference

Reference arm level. The default is the first level.

interval

"bootstrap", "delta" or "none". The default is "delta" for Kaplan-Meier without non-integer weights and "bootstrap" otherwise.

n_boot

Number of bootstrap replicates.

seed

Integer seed for the bootstrap.

conf_level

Confidence level.

Value

A sest_contrast list: arms (data frame of estimand, time, arm, estimate, se, conf_low, conf_high), contrasts (the same columns plus reference, for each arm minus the reference), method, adjustment ("standardised" or "unadjusted"), interval, n_boot, n_boot_failed, seed, conf_level and n. It has a print method and an orchestraManifest::as_orchestra_manifest() method.

Details

Standardised (model-based) fits. For a Cox, parametric, spline or cure fit, every row of data is assigned arm \(a\), its survival curve \(\hat S(t \mid x_i, a)\) is predicted, and the curves are averaged: \(\hat S_a(t) = n^{-1} \sum_i \hat S(t \mid x_i, a)\). A fit made with weights averages with them, \(\hat S_a(t) = \sum_i w_i \hat S(t \mid x_i, a) / \sum_i w_i\), so frequency weights give the contrast of the expanded data and sampling or inverse-probability weights standardise to the population they describe. The RMST of arm \(a\) is the area under \(\hat S_a\) on \([0, \tau]\). Under randomisation these are the survival and RMST the sample would have had if everyone had been assigned \(a\); their differences are causal effects of assignment when the model is right. For a cure fit the cured fraction of each arm, \(n^{-1} \sum_i \hat\pi(x_i, a)\) (weighted in the same way), is contrasted as well.

Unadjusted (Kaplan-Meier). For a fit with method = "km", each arm's Kaplan-Meier curve is computed from data, with the fit's weights, the Greenwood standard error for survival and the standard error of the area for the RMST (Klein and Moeschberger 2003, section 4.5). The fit's right-hand side must be the arm or 1; a fit that also splits by another variable, a strata() term included, is refused.

Intervals. "delta" (Kaplan-Meier only) treats the arms as independent samples and adds the variances. It treats weights as counts, so it is refused with non-integer weights, where survival::survfit() also moves to a robust variance; the default is then "bootstrap". "bootstrap" resamples rows (with their weights) within arm, or, for a fit made with id, whole subjects: within arm when the arm is constant within each subject, across arms otherwise. It refits the model with the same call, and recomputes every quantity: the standard error is the bootstrap standard deviation and the interval is the percentile interval. It is seeded by seed, and the caller's random-number state is restored afterwards. A replicate whose refit fails is counted and reported; more than 10 percent failures is a refusal.

Stratified Cox fits are refused, and so are fits made with subset (fit on the subset rows as data instead). A (start, stop] response is refused: with a time-varying arm the contrast is not an effect of assignment, and sustained-treatment strategies need methods for time-varying treatment, which 'TrialEmulation' and 'lmtp' provide. Horizons beyond the last observed time in any arm are refused.

References

Klein JP, Moeschberger ML. Survival Analysis: Techniques for Censored and Truncated Data, 2nd edition. Springer, 2003. doi:10.1007/b97377

See also

sest_cr_contrast() for competing risks, sest_pseudo() for the pseudo-observation estimator.

Other estimands-and-tests: sest_cr_contrast(), sest_logrank(), sest_ph_check(), sest_pseudo()

Examples

v <- survival::veteran
km <- survestimand(survival::Surv(time, status) ~ trt, v, method = "km")
sest_contrast(km, v, arm = "trt", times = 180, tau = 365)
#> <sest_contrast> km, unadjusted; interval: delta
#>   by arm:
#>  estimand time arm estimate       se conf_low conf_high
#>  survival  180   1   0.2124  0.05142   0.1116    0.3132
#>      rmst  365   1 118.9715 13.02038  93.4521  144.4910
#>  survival  180   2   0.2329  0.05288   0.1292    0.3365
#>      rmst  365   2 112.4041 14.87477  83.2501  141.5581
#> 
#>   contrasts against the reference arm:
#>  estimand time arm reference estimate       se conf_low conf_high
#>  survival  180   2         1  0.02043  0.07376  -0.1241     0.165
#>      rmst  365   2         1 -6.56741 19.76838 -45.3127    32.178
cx <- survestimand(survival::Surv(time, status) ~ trt + karno, v,
                   method = "cox")
sest_contrast(cx, v, arm = "trt", times = 180, tau = 365, n_boot = 20L)
#> <sest_contrast> cox, standardised; interval: bootstrap (20 replicates, seed 1)
#>   by arm:
#>  estimand time arm estimate       se conf_low conf_high
#>  survival  180   1   0.2416  0.03248   0.1928    0.3029
#>      rmst  365   1 122.3682 11.50660 102.6853  140.1490
#>  survival  180   2   0.1964  0.03721   0.1575    0.2663
#>      rmst  365   2 107.1920  8.60804  94.6348  122.0772
#> 
#>   contrasts against the reference arm:
#>  estimand time arm reference  estimate       se  conf_low conf_high
#>  survival  180   2         1  -0.04516  0.04051  -0.09354   0.04577
#>      rmst  365   2         1 -15.17616 13.49622 -31.22028  15.12834