Skip to contents

Plot cumulative incidence and VE estimates for two different methods using colors to distinguish methods

Usage

compare_ve_fits(
  fit1,
  fit2,
  labels = c("Method 1", "Method 2"),
  ci_type = NULL,
  colors = c("#F8766D", "#00BFC4")
)

Arguments

fit1

A vefit object (typically from matching_ve)

fit2

A vefit object (typically from nomatchVE)

labels

Character vector of length 2 providing labels for the two methods. Default is c("Method 1", "Method 2").

ci_type

Character string specifying the type of confidence interval to plot. One of "wald", "percentile", or "simul". If NULL (default), uses the CI type from fit1. If the object has ci_type = "both", defaults to "wald".

colors

Character vector of length 2 providing colors for the two methods. Default is c("#F8766D", "#00BFC4") (ggplot2's default red and cyan).

Value

A ggplot2 object with three faceted panels showing cumulative incidence and VE estimates for both methods.

Details

Both fit1 and fit2 must have the same significance level (alpha). The function will stop with an error if alphas differ.

For cumulative incidence panels, y-axis limits are shared across methods to facilitate comparison. The VE panel uses free y-axis scaling.

Examples

if (FALSE) { # \dontrun{
# Fit both methods
fit_nomatch <- nomatchVE(data = simdata, ...)
fit_match <- matching_ve(matched_data = matched_data, ...)
# Compare with custom labels
compare_ve_fits(
  fit_match,
  fit_nomatch,
  labels = c("Matching", "G-computation"))
} # }