Skip to contents

For use with non-proportional hazards models (survextrap(...,nonprop=TRUE)). Intended as a quick check of a model fit, so there are limited customisation options. The underlying data can be extracted with hazard_ratio.

Usage

plot_hazard_ratio(
  x,
  newdata = NULL,
  t = NULL,
  tmax = NULL,
  niter = NULL,
  ci = TRUE,
  xlab = "Time",
  ylab = "Hazard ratio",
  line_size = 1.5,
  ci_alpha = 0.2
)

Arguments

x

A fitted model object as returned by survextrap

newdata

A data frame with two rows. The hazard ratio will be defined as hazard(second row) divided by hazard(first row). If the only covariate in the model is a factor with two levels, then newdata defaults to a data frame containing the levels of this factor, so that the hazard ratio for the second level versus the first level is computed. For any other models, newdata must be supplied explicitly.

t

Vector of times at which to compute the estimates.

tmax

Maximum time at which to compute the estimates. If t is supplied, then this is ignored. If t is not supplied, then t is set to a set of 100 equally spaced time points from 0 to tmax. If both tmax and t are not supplied, then tmax is set to the maximum follow up time in the data.

niter

Number of MCMC iterations to use to compute credible intervals. Set to a low value to make this function quicker, at the cost of some approximation error (which may not be important for plotting or model development).

ci

If TRUE then credible intervals are drawn. Defaults to drawing the intervals if the plot shows the curve for only one covariate value.

xlab

X-axis label

ylab

Y-axis label

line_size

Passed to geom_line

ci_alpha

Transparency for the credible interval ribbons