# Random effects meta-analysis for correlated test statistics

#### Gabriel Hoffman

Standard approaches to meta-analysis assumes that effect sizes are statistically independent. Here we provide methods for fixed and random effects meta-analysis when the correlation between effect sizes are known.

### Fixed effects meta-analysis

`LS()` implements fixed effect meta-analysis for correlated test statistics using method of Lin and Sullivan (2009). By default, correlation is set to identity matrix to for independent test statistics.

### Random effects meta-analysis

`RE2C()` implements random effect meta-analysis for correlated test statistics that jointly tests deviation of the mean from zero as well as effect size heterogenity. This method uses the RE2 method of Han and Eskin (2011), or RE2 for correlated test statistics from Han et al. (2016). By default, correlation is set to identity matrix to for independent test statistics. (In addition, this function computes the two step RE2C method of Lee, Eskin, and Han (2017) to further test for heterogenity in effect size after applying a fixed effect test.)

- `stat1`: statistic testing effect mean

- `stat2`: statistic testing effect heterogeneity

- `RE2Cp`: RE2 p-value accounting for correlelation between tests. (This is the p-value appropriate for most questions)

- `RE2Cp.twoStep`: two step RE2C test after fixed effect test. Only evaluated if `twoStep==TRUE`. (not typically used)

- `QE`: test statistic for the test of (residual) heterogeneity

- `QEp`: p-value for the test of (residual) heterogeneity

- `Isq`: I^2 statistic

  `QE`, `QEp` and `Isq` are only evaluted if correlation is diagonal

### Examples

    library(remaCor)
    library(metafor)
    library(mvtnorm)
    library(clusterGeneration )

    # sample size
    n = 30

    # number of response variables
    m = 2

    # Error covariance
    Sigma = genPositiveDefMat(m)$Sigma

    # regression parameters
    beta = matrix(0, 1, m)

    # covariates
    X = matrix(rnorm(n), ncol=1)

    # Simulate response variables
    Y = X %*% beta + rmvnorm(n, sigma = Sigma)

    # Multivariate regression
    fit = lm(Y ~ X)

    # Correlation between residuals
    C = cor(residuals(fit))

    # Extract effect sizes and standard errors from model fit
    df = lapply(coef(summary(fit)), function(a)
      data.frame(beta = a["X", 1], se = a["X", 2]))
    df = do.call(rbind, df)

    # Standard fixed effects meta-analysis
    # of independent effects with metafor pacakge
    rma( df$beta, sei=df$se, method="FE")

    ##
    ## Fixed-Effects Model (k = 2)
    ##
    ## I^2 (total heterogeneity / total variability):   0.00%
    ## H^2 (total variability / sampling variability):  0.00
    ##
    ## Test for Heterogeneity:
    ## Q(df = 1) = 0.0029, p-val = 0.9567
    ##
    ## Model Results:
    ##
    ## estimate      se    zval    pval    ci.lb   ci.ub
    ##   0.2698  0.4997  0.5399  0.5893  -0.7095  1.2491
    ##
    ## ---
    ## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    # Standard random effects meta-analysis
    # of independent effects with metafor pacakge
    rma( df$beta, sei=df$se, method="REML")

    ##
    ## Random-Effects Model (k = 2; tau^2 estimator: REML)
    ##
    ## tau^2 (estimated amount of total heterogeneity): 0 (SE = 0.7108)
    ## tau (square root of estimated tau^2 value):      0
    ## I^2 (total heterogeneity / total variability):   0.00%
    ## H^2 (total variability / sampling variability):  1.00
    ##
    ## Test for Heterogeneity:
    ## Q(df = 1) = 0.0029, p-val = 0.9567
    ##
    ## Model Results:
    ##
    ## estimate      se    zval    pval    ci.lb   ci.ub
    ##   0.2698  0.4997  0.5399  0.5893  -0.7095  1.2491
    ##
    ## ---
    ## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    # Run fixed effects meta-analysis, assume identity correlation
    # Use Lin-Sullivan method
    LS( df$beta, df$se)

    ##        beta        se         p
    ## 1 0.2697757 0.4996621 0.5892548

    # Run fixed effects meta-analysis, accounting for correlation
    # Use Lin-Sullivan method
    LS( df$beta, df$se, C)

    ##        beta        se         p
    ## 1 0.2696278 0.4812365 0.5752876

    # Run random effects meta-analysis, assume identity correlation
    RE2C( df$beta, df$se)

    ##       stat1 stat2     RE2Cp RE2Cp.twoStep          QE       QEp Isq
    ## 1 0.2915095     0 0.6324478            NA 0.002944215 0.9567275   0

    # Run random effects meta-analysis, accounting for correlation
    RE2C( df$beta, df$se, C)

    ##       stat1 stat2     RE2Cp RE2Cp.twoStep          QE       QEp Isq
    ## 1 0.3139151     0 0.6207179            NA 0.002944303 0.9741744   0

    ##       stat1 stat2     RE2Cp RE2Cp.twoStep          QE       QEp Isq
    ## 1 0.3139151     0 0.6207179            NA 0.002944303 0.9741744   0

# Session info

    sessionInfo()

    ## R version 4.5.1 (2025-06-13)
    ## Platform: aarch64-apple-darwin23.6.0
    ## Running under: macOS Sonoma 14.7.1
    ##
    ## Matrix products: default
    ## BLAS/LAPACK: /opt/homebrew/Cellar/openblas/0.3.30/lib/libopenblasp-r0.3.30.dylib;  LAPACK version 3.12.0
    ##
    ## locale:
    ## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    ##
    ## time zone: America/New_York
    ## tzcode source: internal
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] clusterGeneration_1.3.8 MASS_7.3-65             mvtnorm_1.3-3
    ## [4] metafor_4.8-0           numDeriv_2016.8-1.1     metadat_1.4-0
    ## [7] Matrix_1.7-3            remaCor_0.0.20          ggplot2_3.5.2
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] gtable_0.3.6       jsonlite_2.0.0     dplyr_1.1.4        compiler_4.5.1
    ##  [5] EnvStats_3.1.0     tidyselect_1.2.1   Rcpp_1.1.0         stringr_1.5.1
    ##  [9] jquerylib_0.1.4    scales_1.4.0       yaml_2.3.10        fastmap_1.2.0
    ## [13] lattice_0.22-7     R6_2.6.1           plyr_1.8.9         generics_0.1.4
    ## [17] knitr_1.50         rbibutils_2.3      tibble_3.3.0       bslib_0.9.0
    ## [21] pillar_1.11.0      RColorBrewer_1.1-3 rlang_1.1.6        stringi_1.8.7
    ## [25] cachem_1.1.0       mathjaxr_1.8-0     xfun_0.52          sass_0.4.10
    ## [29] cli_3.6.5          withr_3.0.2        magrittr_2.0.3     Rdpack_2.6.4
    ## [33] digest_0.6.37      grid_4.5.1         nlme_3.1-168       lifecycle_1.0.4
    ## [37] vctrs_0.6.5        evaluate_1.0.4     glue_1.8.0         farver_2.1.2
    ## [41] codetools_0.2-20   reshape2_1.4.4     rmarkdown_2.29     tools_4.5.1
    ## [45] pkgconfig_2.0.3    htmltools_0.5.8.1

## References

Han, Buhm, Dat Duong, Jae Hoon Sul, Paul IW de Bakker, Eleazar Eskin, and Soumya Raychaudhuri. 2016. “A General Framework for Meta-Analyzing Dependent Studies with Overlapping Subjects in Association Mapping.” Human Molecular Genetics 25 (9): 1857–66. https://doi.org/10.1093/hmg/ddw049.
Han, Buhm, and Eleazar Eskin. 2011. “Random-Effects Model Aimed at Discovering Associations in Meta-Analysis of Genome-Wide Association Studies.” The American Journal of Human Genetics 88 (5): 586–98. https://doi.org/10.1016/j.ajhg.2011.04.014.
Lee, CH, Eleazar Eskin, and Buhm Han. 2017. “Increasing the Power of Meta-Analysis of Genome-Wide Association Studies to Detect Heterogeneous Effects.” Bioinformatics 33 (14): i379–88. https://doi.org/10.1093/bioinformatics/btx242.
Lin, Dan-Yu, and Patrick F Sullivan. 2009. “Meta-Analysis of Genome-Wide Association Studies with Overlapping Subjects.” The American Journal of Human Genetics 85 (6): 862–72. https://doi.org/10.1016/j.ajhg.2009.11.001.