powered by
This function extracts Schoenfeld residuals from a fitted cox.zph object and formats them into a tidy data frame.
cox.zph
get_schoenfeld(fit_zph)
A tibble with the Schoenfeld residuals in long format, containing the columns:
The time variable from the Cox model.
The transformation applied to the time variable.
The variable names from the Cox model for which residuals are calculated.
The Schoenfeld residuals for each variable at each time point.
An object of class cox.zph produced by the cox.zph function, representing the Schoenfeld residuals of a Cox proportional hazards model.
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)
Run the code above in your browser using DataLab