plot_schoenfeld {easysurv} | R Documentation |
Plot Schoenfeld Residuals
Description
Plot the residuals generated by the get_schoenfeld
function.
This function creates a visual representation of Schoenfeld residuals from a
Cox proportional hazards model.
It allows for customization of the plot, including the addition of horizontal
and smoothed lines, and styling of points and plot elements.
Usage
plot_schoenfeld(
residuals,
hline = TRUE,
sline = TRUE,
sline_se = TRUE,
hline_col = "#F8766D",
hline_size = 1,
hline_alpha = 1,
hline_yintercept = 0,
hline_lty = "dashed",
sline_col = "#00BFC4",
sline_size = 1,
sline_alpha = 0.2,
sline_lty = "dashed",
point_col = "black",
point_size = 1,
point_shape = 19,
point_alpha = 1,
plot_theme = ggplot2::theme_bw()
)
Arguments
residuals |
A data frame containing the Schoenfeld residuals, typically
with columns |
hline |
Logical. If |
sline |
Logical. If |
sline_se |
Logical. If |
hline_col |
Color of the horizontal line. Default is |
hline_size |
Line width of the horizontal line. Default is |
hline_alpha |
Transparency of the horizontal line. Default is |
hline_yintercept |
Y-intercept for the horizontal line. Default is |
hline_lty |
Line type for the horizontal line. Default is |
sline_col |
Color of the smooth line. Default is |
sline_size |
Line width of the smooth line. Default is |
sline_alpha |
Transparency of the smooth line. Default is |
sline_lty |
Line type for the smooth line. Default is |
point_col |
Color of the points representing residuals. Default is
|
point_size |
Size of the points representing residuals. Default is |
point_shape |
Shape of the points representing residuals. Default is
|
point_alpha |
Transparency of the points representing residuals. Default
is |
plot_theme |
A ggplot2 theme for the plot. Default is
|
Value
A ggplot object representing the plot of Schoenfeld residuals.
Examples
library(survival)
test_fit <- survival::coxph(survival::Surv(time, status) ~ sex, data = lung)
test_fit_zph <- survival::cox.zph(test_fit)
plot_schoenfeld(get_schoenfeld(test_fit_zph))