
Plot the hazard ratio of a covariate as a function of landmark time
Source:R/superlandmarking.R
plot_hazard_ratio.RdPlot the hazard ratio of a covariate as a function of landmark time
Usage
plot_hazard_ratio(
x,
covariate,
landmarks,
w,
type = c("crude", "supermodel", "both"),
contrast = 1,
newdata = NULL,
level = 0.95
)Arguments
- x
An object of class
LandmarkAnalysis.- covariate
Character name of the (numeric) covariate to compute the hazard ratio for.
- landmarks
Numeric vector of landmark times. For
type = "crude", a fit must already exist inx@survival_fitsfor each landmark (viafit_survival) at windoww; fortype = "supermodel", a superlandmark model must already exist for thislandmarks/wpair (viafit_superlandmark).- w
Scalar prediction window, as passed to
fit_survival(horizonslandmarks + w) and/orfit_superlandmark.- type
Whether to plot the crude per-landmark estimates, the pooled supermodel curve, or both.
- contrast
Numeric increase in
covariateto compute the hazard ratio for (defaults to 1, i.e. the usual per-unit hazard ratio).- newdata
A single-row
data.framegiving values for every other covariate in the model (excludingcovariateandLM). Defaults to the mean/first level of each fromx@data_static.- level
Confidence level for the pointwise intervals (default 0.95).
Value
A ggplot object.
Details
For every landmark time, the hazard ratio associated with a
contrast-unit increase in covariate is computed as
\(\log(HR) = (x_1 - x_0)^\top \hat\beta\).
Any other covariate present in the formula is held fixed at the mean
(numeric) or first level (factor) of x@data_static, unless
overridden via newdata.