Skip to contents

Draws every method's hazard ratio with its 95% confidence interval on a log scale, a grey line at the null (HR 1), and a dashed line at the randomised ground truth. The reportable MSM row is highlighted.

Usage

plot_forest(
  forest,
  truth,
  title = "Only the MSM recovers the causal effect",
  subtitle = NULL,
  caption = NULL
)

Arguments

forest

A forest table from build_forest().

truth

The ground-truth hazard ratio from oracle_hr().

title

Plot title.

subtitle

Plot subtitle. If NULL, a default naming the truth is used.

caption

Plot caption. If NULL, a default teaching caption is used.

Value

A ggplot2::ggplot() object.

Examples

dat <- simulate_hr_agent(n = 2000)
f <- build_forest(fit_all_models(dat))
#> Warning: The default delta method standard errors for `coxph` models only take into account uncertainty in the regression coefficients. Standard errors may be too small. Use the `inferences()` function or set `vcov` to "rsample", "boot"  or "fwb" to compute confidence intervals by bootstrapping. Set `vcov` to `FALSE` or `options(marginaleffects_safe=FALSE)` to silence this warning.
#> Warning: The default delta method standard errors for `coxph` models only take into account uncertainty in the regression coefficients. Standard errors may be too small. Use the `inferences()` function or set `vcov` to "rsample", "boot"  or "fwb" to compute confidence intervals by bootstrapping. Set `vcov` to `FALSE` or `options(marginaleffects_safe=FALSE)` to silence this warning.
# \donttest{
plot_forest(f, truth = oracle_hr(n = 5e4))

# }