get_schoenfeld {easysurv} | R Documentation |
This function extracts Schoenfeld residuals from a fitted cox.zph
object
and formats them into a tidy data frame.
get_schoenfeld(fit_zph)
fit_zph |
An object of class |
A tibble with the Schoenfeld residuals in long format, containing the columns:
time |
The time variable from the Cox model. |
transform |
The transformation applied to the time variable. |
variable |
The variable names from the Cox model for which residuals are calculated. |
residual |
The Schoenfeld residuals for each variable at each time point. |
library(survival)
test_fit <- survival::coxph(survival::Surv(time, status) ~ sex, data = lung)
test_fit_zph <- survival::cox.zph(test_fit)
get_schoenfeld(test_fit_zph)