Skip to contents

One residual per EVENT (not per subject): the covariate value of the subject who failed, minus the risk-weighted mean over the risk set. Under proportional hazards they have no trend in time, so the correlation with transformed time is a direct test of PH.

Usage

morie_cox_schoenfeld_residuals(fit, transform = c("km", "rank", "identity"))

Arguments

fit

a Cox fit, as for morie_cox_martingale_residuals.

transform

"km" (1 - Kaplan-Meier, the default), "rank" or "identity".

Value

list with residuals (events x p), times, correlation and p_value per covariate.

Details

A significant trend means the hazard ratio moves over follow-up. The response is to stratify on the offending covariate or model it with a time interaction – not to drop it, which changes the question rather than answering it.

References

Grambsch, P. M. and Therneau, T. M. (1994). Proportional hazards tests and diagnostics based on weighted residuals. Biometrika, 81(3), 515-526.

Examples

set.seed(1)
X <- matrix(rnorm(80), ncol = 2)
tt <- rexp(40, exp(X %*% c(0.6, 0)))
f <- morie_efron_tie_correction(tt, rep(1, 40), X)
round(morie_cox_schoenfeld_residuals(f)$p_value, 3)
#> [1] 0.559 0.352