Introduction to metaLong"

knitr::opts_chunk$set(
  collapse  = TRUE,
  comment   = "#>",
  fig.width = 6,
  fig.height = 4
)

Overview

metaLong provides a coherent workflow for synthesising evidence from studies that report outcomes at multiple follow-up time points. The package covers:

1. Simulating data

library(metaLong)

dat <- sim_longitudinal_meta(
  k    = 10,
  times = c(0, 6, 12, 24),
  mu   = c("0" = 0.30, "6" = 0.50, "12" = 0.42, "24" = 0.20),
  tau  = 0.20,
  seed = 42
)

head(dat, 6)

The data are in long format: one row per study x time combination.

2. Longitudinal pooling: ml_meta()

ml_meta() fits an intercept-only random-effects model at each time point with CR2 sandwich variance and Satterthwaite degrees of freedom.

meta <- ml_meta(dat, yi = "yi", vi = "vi", study = "study", time = "time")
print(meta)
plot(meta, main = "Pooled Effects Across Follow-Up")

3. Sensitivity analysis: ml_sens()

ml_sens() computes ITCV_alpha(t) — the minimum partial correlation an omitted confounder must have with both treatment and outcome to render the result non-significant.

sens <- ml_sens(dat, meta, yi = "yi", vi = "vi",
                study = "study", time = "time")
print(sens)
plot(sens)

Key trajectory summaries:

cat("Minimum ITCV_alpha:", round(attr(sens, "itcv_min"),  3), "\n")
cat("Mean ITCV_alpha:   ", round(attr(sens, "itcv_mean"), 3), "\n")
cat("Fragile proportion:", round(attr(sens, "fragile_prop"), 3), "\n")

4. Nonlinear time trend: ml_spline()

spl <- ml_spline(meta, df = 2)
print(spl)
plot(spl, main = "Spline Fit: Nonlinear Trajectory")

5. Combined figure: ml_plot()

ml_plot(meta, sens_obj = sens, spline_obj = spl,
        main = "Longitudinal Meta-Analysis Profile")

6. Benchmark calibration: ml_benchmark()

ml_benchmark() regresses each observed study-level covariate and flags those whose partial correlation exceeds the ITCV_alpha threshold.

bench <- ml_benchmark(
  dat, meta, sens,
  yi         = "yi", vi = "vi", study = "study", time = "time",
  covariates = c("pub_year", "quality")
)
print(bench)

7. Fragility analysis: ml_fragility()

The fragility index is the minimum number of study removals that flip significance at a given time point.

frag <- ml_fragility(dat, meta,
                     yi = "yi", vi = "vi", study = "study", time = "time",
                     max_k = 1L, seed = 1)
print(frag)

8. Accessing stored fits

f <- fits(meta)
cat("Stored model objects:", sum(!sapply(f, is.null)), "/", length(f), "\n")

References

Frank, K. A. (2000). Impact of a confounding variable on a regression coefficient. Sociological Methods & Research, 29(2), 147--194.

Hedges, L. V., Tipton, E., & Johnson, M. C. (2010). Robust variance estimation in meta-regression with dependent effect size estimates. Research Synthesis Methods, 1(1), 39--65.

Tipton, E. (2015). Small sample adjustments for robust variance estimation with meta-regression. Psychological Methods, 20(3), 375--393.



Try the metaLong package in your browser

Any scripts or data that you put into this service are public.

metaLong documentation built on March 31, 2026, 1:07 a.m.