Skip to contents

Splits follow-up at event-time quantiles and fits a separate coefficient in each interval, with a likelihood-ratio test against the constant-coefficient fit.

Usage

morie_cox_time_varying(time, event, X, n_intervals = 3, ties = "efron")

Arguments

time

follow-up times.

event

1 for an event, 0 for censored.

X

covariate matrix.

n_intervals

number of follow-up intervals.

ties

tie correction.

Value

list with beta (intervals x p), se, z, p_value, cutpoints, events_per_interval, constant_beta, lr_vs_constant, p_vs_constant.

Details

This is the time-varying COEFFICIENT, not the time-varying covariate – the covariate is fixed and its effect is allowed to change. It is the direct fix when morie_cox_schoenfeld_residuals shows proportional hazards failing.

Late intervals routinely hold very few events, and a hazard ratio estimated from three of them is not informative however clean it looks. Read events_per_interval first.

References

Therneau, T. M. and Grambsch, P. M. (2000). Modeling Survival Data, Sec. 6.5. Springer.

Examples

set.seed(6)
X <- matrix(rnorm(200), ncol = 1)
tt <- rexp(200, exp(X * 0.6))
morie_cox_time_varying(tt, rep(1, 200), X)$events_per_interval
#> [1] 67 66 67