Skip to contents

Test each term of a Cox fit for a hazard ratio that changes with time, and estimate the hazard ratio in separate time windows.

Usage

sest_ph_check(
  fit,
  transform = c("km", "identity", "log", "rank"),
  cuts = NULL,
  conf_level = 0.95
)

Arguments

fit

A sest_fit of kind "cox" from method = "cox".

transform

Time transform for the test: "km" (default), "identity", "log" or "rank".

cuts

Interior cut points (in time units) for the hazard ratio by window. The default cuts at the tertiles of the event times.

conf_level

Confidence level for the window intervals.

Value

A sest_ph_check list: test (data frame of term, chisq, df, p_value, with a final GLOBAL row), hr_by_window (data frame of window, start, end, events, term, log_hr, se, hr, conf_low, conf_high), transform and cuts.

Details

The test is the score test of Grambsch and Therneau (1994) for adding \(\gamma_k\, x_k\, g(t)\) to the model, evaluated at the fitted \(\hat\beta\) and \(\gamma = 0\). Its score is the sum over events of the Schoenfeld residual times \(g(t)\); its information is the full \(2p \times 2p\) matrix, so the statistic for a term is the score's quadratic form in the Schur complement of the \(\beta\) block. Ties are handled as the fit handled them (Efron or Breslow). transform = "km" uses \(g(t) = 1 - \hat S(t-)\), the left-continuous Kaplan-Meier estimate of the pooled sample; "identity", "log" and "rank" are the alternatives.

The hazard ratio over time comes from one Cox fit per window \((c_{k-1}, c_k]\), with entry at \(c_{k-1}\) (left truncation). Because every risk set lies inside one window, these fits equal the window-by-covariate interaction model with a common baseline.

Stratified, counting-process, weighted and penalised fits, and fits with ties = "exact", are refused.

References

Grambsch PM, Therneau TM. Proportional hazards tests and diagnostics based on weighted residuals. Biometrika 1994; 81(3): 515-526. doi:10.1093/biomet/81.3.515

Examples

fit <- survestimand(survival::Surv(time, status) ~ trt + karno,
               survival::veteran, method = "cox")
sest_ph_check(fit, cuts = c(60, 180))
#> <sest_ph_check> transform = km
#>    term   chisq df   p_value
#>     trt  0.3072  1 0.5794205
#>   karno 11.9588  1 0.0005439
#>  GLOBAL 13.5769  2 0.0011267
#> 
#>   hazard ratio by time window:
#>  window start end events  term     hr conf_low conf_high
#>       1     0  60     63   trt 1.1869   0.7147    1.9713
#>       1     0  60     63 karno 0.9533   0.9412    0.9655
#>       2    60 180     40   trt 0.9663   0.4987    1.8723
#>       2    60 180     40 karno 0.9919   0.9709    1.0135
#>       3   180 Inf     25   trt 0.5572   0.2042    1.5204
#>       3   180 Inf     25 karno 1.0011   0.9679    1.0354