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 time, residual, transform, and variable.

hline

Logical. If TRUE, a horizontal line is added to the plot. Default is TRUE.

sline

Logical. If TRUE, a smooth line is added to the plot. Default is TRUE.

sline_se

Logical. If TRUE, confidence intervals are displayed around the smooth line. Default is TRUE.

hline_col

Color of the horizontal line. Default is "#F8766D" (red).

hline_size

Line width of the horizontal line. Default is 1.

hline_alpha

Transparency of the horizontal line. Default is 1.

hline_yintercept

Y-intercept for the horizontal line. Default is 0.

hline_lty

Line type for the horizontal line. Default is "dashed".

sline_col

Color of the smooth line. Default is "#00BFC4" (blue).

sline_size

Line width of the smooth line. Default is 1.

sline_alpha

Transparency of the smooth line. Default is 0.2.

sline_lty

Line type for the smooth line. Default is "dashed".

point_col

Color of the points representing residuals. Default is "black".

point_size

Size of the points representing residuals. Default is 1.

point_shape

Shape of the points representing residuals. Default is 19.

point_alpha

Transparency of the points representing residuals. Default is 1.

plot_theme

A ggplot2 theme for the plot. Default is ggplot2::theme_bw().

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))

[Package easysurv version 2.0.1 Index]