Generates a plot showing the spline-transformed effect of a continuous variable in a Cox model using predicted marginal effects with confidence intervals.
Usage
cox_plot_spline(
data_model,
spline_var = "age_bs",
title = "Spline effect",
xlab = NULL,
ylab = "Predicted risk",
color = "#0072B2"
)Arguments
- data_model
A fitted Cox proportional hazards model object created with `coxph()` and spline terms (e.g., using `splines::bs()`).
- spline_var
Character string specifying the name of the spline variable in the model to visualize (e.g., `"age_bs"` or `"bmi"`).
- title
Character string specifying the title of the plot. Default is `"Spline effect"`.
- xlab
Optional label for the x-axis. If `NULL`, the variable name will be used.
- ylab
Label for the y-axis. Default is `"Predicted risk"`.
- color
Character string with a valid color for the line and confidence ribbon. Default is Bootstrap blue `"#0072B2"`.
Value
A `ggplot` object showing the effect of the spline-transformed variable with a confidence ribbon.
