Forest plot of contrasts at a reference time

Description

Extract the row(s) of x$contrasts at t_ref and render a horizontal forest plot: one row per contrast, with point estimate, 95% CI (from x$ci_method), and a textual label. Only available for contrast-shaped types (risk_difference, risk_ratio, rmst_difference).

Usage

## S3 method for class 'survatr_result'
forrest(x, t_ref, col = NULL, main = NULL, xlab = NULL, ...)

Arguments

x A survatr_result.
t_ref Numeric scalar; must be in x$time_grid.
col Single color for point + segment. Default grDevices::palette()[1].
main Optional plot title.
xlab Optional x-axis label.
Passed to plot.default().

Value

The survatr_result, invisibly.

See Also

Other survatr_result methods: contrast(), contrast.survatr_fit(), forrest(), plot.survatr_result(), print.survatr_result(), tidy.survatr_result()

Examples

library("survatr")

set.seed(2)
n_id <- 40L
K <- 5L
pp <- data.frame(
  id = rep(seq_len(n_id), each = K),
  t = rep(seq_len(K), times = n_id),
  A = rep(rbinom(n_id, 1L, 0.5), each = K),
  Y = rbinom(n_id * K, 1L, 0.1)
)
fit <- surv_fit(pp, "Y", "A", ~1, "id", "t", time_formula = ~ factor(t))
res <- contrast(
  fit,
  interventions = list(a1 = causatr::static(1), a0 = causatr::static(0)),
  times = 1:5,
  type = "risk_difference",
  ci_method = "sandwich"
)
forrest(res, t_ref = 5)