Skip to contents

This vignette follows the software-paper illustrations (Panaro et al. 2025): immunotherapy-by-age on age, then REACT corticosteroids on steroids, including trial-level shrinkage and incomplete subgroup designs.

Immunotherapy by age (age)

The age table is from a review of disease-modifying immunotherapies in relapsing–remitting multiple sclerosis (Heesen et al. 2024): do treatments reduce relapses equally in Younger and Older patients when only aggregate subgroup summaries are available? Published tables quote incidence rate ratios; values below one favour immunotherapy. Trial ADVANCE anchors the shrinkage figures in the paper (?shrinkage).

library(interactmeta)

age[age$study == "ADVANCE", c("study", "subgroup", "yi", "vi")]
#> # A tibble: 2 × 4
#>   study   subgroup     yi     vi
#>   <chr>   <chr>     <dbl>  <dbl>
#> 1 ADVANCE Younger  -0.342 0.0222
#> 2 ADVANCE Older    -0.654 0.0606

age uses study and subgroup for trial and level names. In cams() and ifrac() you can remap columns with trial / subgroup or pass a single modifier column instead of subgroup.

With reference Younger, ifrac() adds IF_Older =πj=\pi_j on each row (Panaro et al. 2025).

des_age <- ifrac(age, reference = "Younger")

des_age[des_age$study == "ADVANCE",
        c("study", "level", "yi", "vi", "IF_Older")]
#> # A tibble: 2 × 5
#>   study   level       yi     vi IF_Older
#>   <chr>   <fct>    <dbl>  <dbl>    <dbl>
#> 1 ADVANCE Older   -0.654 0.0606    0.268
#> 2 ADVANCE Younger -0.342 0.0222    0.268

contrast = NULL keeps subgroup rows only (wide IF_* columns). include_interaction = TRUE appends within-trial contrast rows; contrast = c("Older", "Younger") targets one contrast. [?ifrac] documents big_var, contrast_sep, and include_combined.

For ADVANCE, IF_Older is approximately 0.2680.268. The Bayesian CAMS fit below uses half-normal priors on τ\tau and τγ\tau_\gamma as in the paper (Panaro et al. 2026) (not the package’s improper defaults).

fit_age <- cams(
  des_age,
  reference = "Younger",
  tau.prior = function(tau) bayesmeta::dhalfnormal(tau, scale = 0.5),
  tau.interaction.prior = function(tau_gamma)
    bayesmeta::dhalfnormal(tau_gamma, scale = 0.1)
)

print(fit_age)
#>  'interactmeta' object.
#> 
#> 7 trials, 2 Level levels (reference: Younger):
#> ADVANCE, AFFIRM, CONFIRM-B, CONFIRM-C, DEFINE, FREEDOMS, TEMSO
#> Level levels: Older, Younger
#> 
#> method: Bayesian
#> 
#> Bayesian model results:
#>            tau tau_gamma Intercept Ecological_Older Interaction_Older
#> mode      0.25      0.01     -0.48            -0.37              0.38
#> median    0.30      0.09     -0.47            -0.38              0.38
#> mean      0.32      0.10     -0.47            -0.38              0.38
#> sd        0.13      0.07      0.63             1.55              0.11
#> 95% lower 0.14      0.00     -1.74            -3.52              0.17
#> 95% upper 0.65      0.25      0.81             2.75              0.59
#> 
#> (Quoted intervals are central credible intervals; combined via bmr, interaction via bayesmeta.)
#> Use summary() for heterogeneity, IF, and derived effects.

Without custom priors, Bayesian cams() uses improper uniform τ\tau priors (matching bayesmeta defaults). Set method = "REML" or "ML" for a metafor fit, or fixed.prior for normal priors on block means. precompute = TRUE warms caches eagerly; lazy_latent = TRUE (default) defers latent convolves until summary(), tidy(), or plotting. Pass fit_args = list(n_support = …) to control quadrature resolution.

plot(fit_age, type = "contribution", exponentiate = TRUE)

The horizontal axis is the IF assigned to Older patients (precision-based, not enrolment share). The same plot() method offers type = "heterogeneity" (τ\tau components) and type = "forest" (modifier panels). Use exponentiate = TRUE on log-scale outcomes (IRR / OR); at or ifrac on the plot match modifiers() and combined().

The modifier forest defaults to type = "modifiers" (reference and non-reference panels, optional Combined via include_combined). The interaction forest uses type = "interaction". Toggle layers with include_shrinkage, include_overall, and include_prediction; pass include_shrinkage = FALSE to drop grey CAMS shrinkage rows. Set n_var = "n" for a patient-count column, group = "trial" to nest by study, or favours = FALSE to omit directional labels. Pooled summary diamonds follow ifrac = "interaction" by default; see the steroids section for ifrac = "combined".

Grey diamonds on the modifier forest are trial-level CAMS shrinkage at each πj\pi_j (shrinkage() with type = "modifiers" or "interaction"; same labels as forestplot()).

REACT corticosteroids (steroids)

The steroids table is from the WHO REACT meta-analysis of systemic corticosteroids for COVID-19 mortality (WHO Rapid Evidence Appraisal for COVID-19 Therapies (REACT) Working Group et al. 2020). Subgroups are IMV and Non-IMV; some trials report only one ventilation stratum (not missing data). Values below one on the exponentiated scale favour corticosteroids.

library(metafor)

steroids_es <- escalc(
  measure = "OR",
  ai = treat.events, bi = treat.total - treat.events,
  ci = cont.events, di = cont.total - cont.events,
  data = steroids
)
des <- ifrac(steroids_es, reference = "Non-IMV")

Any metafor::escalc layout works if yi and vi are on the long table. ifrac() accepts escalc output or a data frame; override trial / modifier when column names differ from study / level. The design step is the same as for age: choose reference, then optional contrast and include_interaction before cams().

For IMV-only trials, ifrac() adds a high-variance placeholder (big_var, default 10410^4 on the log scale). For RECOVERY, the reported IMV row is retained and Non-IMV is filled with yi = 0, vi = 10000.

des[des$study == "RECOVERY", c("study", "level", "yi", "vi")]
#> # A tibble: 2 × 4
#>   study    level       yi         vi
#>   <chr>    <fct>    <dbl>      <dbl>
#> 1 RECOVERY IMV     -0.534     0.0209
#> 2 RECOVERY Non-IMV  0     10000

Tune big_var when single-arm imputations are too influential or too diffuse. cams() also accepts contrast_sep and big_var so the fit stage matches the design object.

CAMS separates within-trial interactions gjg_j and combined coordinates mjm_j(Panaro et al. 2025). Heterogeneity τ\tau and τγ\tau_\gamma are separate blocks; see vignette("heterogeneity-after-cams").

fit_reml <- cams(des, reference = "Non-IMV", method = "REML")

This line uses frequentist REML; method = "ML" is also supported. The default method = "Bayesian" path matches the age section (cams() picks bayesmeta or metafor from method).

print(fit_reml)
#>  'interactmeta' object.
#> 
#> 7 trials, 2 Level levels (reference: Non-IMV):
#> CAPE COVID, CoDEX, COVID STEROID, DEXA-COVID 19, RECOVERY, REMAP-CAP, Steroids-SARI
#> Level levels: IMV, Non-IMV
#> 
#> method: REML
#> 
#> REML model results:
#>           tau tau_gamma Intercept Ecological_IMV Interaction_IMV
#> estimate 0.00         0      0.29          -0.77            1.35
#> se         NA        NA      0.62           0.66            0.52
#> zval       NA        NA      0.47          -1.17            2.58
#> pval       NA        NA      0.64           0.24            0.01
#> ci.lb    0.00         0     -0.92          -2.06            0.32
#> ci.ub    1.25         0      1.50           0.52            2.38
#> 
#> (quoted intervals are Wald confidence intervals from the stored rma covariance.)
#> Use summary() for heterogeneity, IF, and derived effects.

summary() and print() honour digits and prob. summary() can exponentiate = TRUE for ratio-scale reporting. For one long export table, tidy() collects interaction, modifier, combined, and heterogeneity rows.

At the default interaction-weighted reporting IF:

interactions(fit_reml, type = "Overall", exponentiate = TRUE)
#> interaction  type     estimate    se  Overall 95% CI
#> IMV-Non-IMV  Overall      3.86  2.02   (1.38, 10.78)
modifiers(fit_reml, type = "Overall", exponentiate = TRUE)
#>   level  type     estimate    se  Overall 95% CI
#>     IMV  Overall      1.47  0.47    (0.78, 2.77)
#> Non-IMV  Overall      0.38  0.15    (0.18, 0.82)
combined(fit_reml, type = "Overall", exponentiate = TRUE)
#> combined  estimate    se  Overall 95% CI
#> Combined      0.85  0.21    (0.53, 1.36)
ifrac(fit_reml, ifrac = "interaction")
#>                   IF  estimate
#> interaction-weighted      0.59
#> (at fitted interaction heterogeneity τ_γ)

interactions() is free of the reporting IF; modifiers() and combined() pool at ifrac = "interaction" (default) or ifrac = "combined". Instead of pooling, pass an explicit combined IF with at = …. Request type = c("Overall", "Prediction") for new-trial prediction intervals. Change prob for other coverage levels; set shrinkage = TRUE to return trial-level CAMS shrinkage tables from the same calls.

REML estimates of τ\tau and τγ\tau_\gamma can be zero on this example, so prediction intervals may coincide with pooled confidence intervals; that does not establish absence of heterogeneity in general.

favours sets left/right benefit labels under the axis; with favours = NULL, defaults follow outcome = "unfavorable" or "favorable". Frequentist forests omit shrinkage rows unless you refit with a Bayesian method. Pre-build with forestplot() and size the device with forestplot_height() before saving or knitting figures.

Trial-level πj\pi_j and the pooled interaction are unchanged when the reporting IF changes. Evaluating modifiers and forests at the overall-effect-weighted fraction moves pooled summaries along the same fitted curves:

ifrac(fit_reml, ifrac = "combined")
#>                IF  estimate
#> combined-weighted      0.92
#> (at fitted heterogeneity τ)
modifiers(fit_reml, ifrac = "combined", exponentiate = TRUE, type = "Overall")
#>   level  type     estimate    se  Overall 95% CI
#>     IMV  Overall      0.73  0.09    (0.58, 0.92)
#> Non-IMV  Overall      0.19  0.09    (0.07, 0.50)
combined(fit_reml, ifrac = "combined", exponentiate = TRUE, type = "Overall")
#> combined  estimate    se  Overall 95% CI
#> Combined      0.66  0.07    (0.53, 0.82)

Here forestplot() passes ifrac = "combined" so pooled Overall / Prediction diamonds and x-axis annotations use overall-effect weights, while observed study rows stay at each trial’s πj\pi_j. The same ifrac switch applies in modifiers(), combined(), and plot().

Next steps

DA, AD, and SWADA on the same des object are in vignette("comparing-da-ad-swada"). More tables: vignette("worked-examples").

Heesen, Christoph, Christian Röver, Sarah Salem, et al. 2024. “Treatment Effect Modifiers of Immunotherapies for Relapsing-Remitting Multiple Sclerosis: A Systematic Review and Meta-Analysis.” Mult Scler J Exp Transl Clin 10 (4): 20552173241274618.
Panaro, Renato Valladares, Christian Röver, and Tim Friede. 2025. “Consistent Bayesian Meta-Analysis on Subgroup Specific Effects and Interactions.” arXiv Preprint arXiv:2512.18785, ahead of print. https://doi.org/10.48550/arXiv.2512.18785.
Panaro, Renato Valladares, Christian Röver, and Tim Friede. 2026. “Empirical Prior Distributions for Treatment-by-Subgroup Interaction Heterogeneity in Random-Effects Meta-Analysis.” arXiv Preprint arXiv:2606.23968, ahead of print. https://doi.org/10.48550/arXiv.2606.23968.
WHO Rapid Evidence Appraisal for COVID-19 Therapies (REACT) Working Group, Jonathan A. C. Sterne, Srinivas Murthy, et al. 2020. “Association Between Administration of Systemic Corticosteroids and Mortality Among Critically Ill Patients with COVID-19: A Meta-Analysis.” JAMA 324 (13): 1330–41.