Skip to contents

plot_smooth_hr() draws the curve of a smooth_hr() result: the (log) hazard ratio across the range of a continuous covariate, with its pointwise confidence band, and a dashed line at no effect.

Usage

plot_smooth_hr(
  result,
  scale = c("log_hr", "hr"),
  title = NULL,
  xlab = NULL,
  ylab = NULL
)

Arguments

result

A smooth_hr() result.

scale

"log_hr" (the default) for the log hazard ratio, or "hr" for the hazard ratio.

title

An optional plot title.

xlab, ylab

The axis labels. The default xlab is the covariate's name, and the default ylab depends on scale.

Value

A ggplot object.

Examples

fit <- cox_ph(Surv(time, status) ~ age + sex, data = lung)
plot_smooth_hr(smooth_hr(fit, term = "age"))

plot_smooth_hr(smooth_hr(fit, term = "age", df = 5), scale = "hr")