Lightweight R tools for benchmarking and calibrating real-world evidence (RWE) studies that emulate randomized clinical trials (RCTs). Implements the three pre-specified agreement metrics from RCT-DUPLICATE (Wang et al., JAMA 2023) and ENCORE (Weberpals et al., CPT 2026), and the BenchExCal calibration framework (Wang et al., CPT 2025).
# from a local tarball
install.packages("benchexcal_0.1.0.tar.gz", repos = NULL, type = "source")
# or from the source directory
# install.packages("path/to/benchexcal", repos = NULL, type = "source")
ggplot2 is suggested for forest and tipping-point plots; everything else
runs on base R.
agreement() — three metrics from RCT-DUPLICATE / ENCOREagreement(
rct_hr = 0.87, rct_lower = 0.78, rct_upper = 0.97,
rwe_hr = 0.82, rwe_lower = 0.76, rwe_upper = 0.87
)
#> RCT-DUPLICATE / ENCORE agreement metrics
#> ----------------------------------------
#> RCT estimate: HR = 0.87 (95% CI: 0.78, 0.97)
#> RWE estimate: HR = 0.82 (95% CI: 0.76, 0.87)
#> Trial type: superiority
#>
#> [1] Statistical significance agreement: YES (full)
#> [2] Estimate agreement: YES
#> [3] Standardized difference agreement: YES (z = 0.90)
For noninferiority trials, pass trial_type = "noninferiority" and
ni_margin = ... to enable partial-SA (SAP).
calibrate() — BenchExCal Stage 2 calibrationInputs (call calibration_inputs() for a reminder):
cal <- calibrate(
stage1_rct_hr = 0.87, stage1_rct_lower = 0.78, stage1_rct_upper = 0.97,
stage1_rwe_hr = 0.82, stage1_rwe_lower = 0.76, stage1_rwe_upper = 0.87,
stage2_rwe_hr = 0.85, stage2_rwe_lower = 0.78, stage2_rwe_upper = 0.93
)
print(cal)
plot(cal) # forest plot of all four estimates
tp <- tipping_point(cal)
print(tp)
plot(tp) # ribbon of HR vs xi_2, with tipping point flagged
For a Stage 1 RCT effect θ̂₁ and Stage 1 RWE effect θ̂₁ with variances V₁ and V₁ (derived from the reported 95% CIs), the divergence is ξ̂₁ = θ̂*₁ − θ̂₁. Rescaled to the Stage 2 scale, ξ̂₂ = √(V₂ / V₁) · ξ̂₁. The calibrated Stage 2 log HR shifts the uncalibrated estimate to remove this bias, θ̂₂,cal = θ̂*₂ − ξ̂₂, with variance inflated to reflect prior uncertainty about ξ₂, V₂,cal = V₂ + (V₁ + V₁) · V₂/V₁. The tipping-point analysis sweeps ξ₂ across its prior 95% range to identify whether the regulatory conclusion (CI excluding HR = 1) is robust.