Random-Effects Meta-Analysis
The engine for Diverse Synthesis. This model audits a cluster of studies by assuming each represents a unique 'Satellite' of a broader truth, reveal the global average while mathematically respecting between-study heterogeneity.
What is it?
Random-Effects Meta-Analysis is designed to mathematically synthesize evidence across multiple independent studies to resolve clinical uncertainty.
The engine for Diverse Synthesis. This model audits a cluster of studies by assuming each represents a unique 'Satellite' of a broader truth, reveal the global average while mathematically respecting between-study heterogeneity.
Goals & Indications
- Heterogeneity Neutralization: Correct for the 'Between-Study' variability that naturally occurs in real-world clinical data.
- Population Generalization: Estimate an effect that applies to the entire universe of potential studies, not just the ones in your pool.
- Conservative Precision Discovery: Provide a more realistic and wider confidence interval that acknowledges the diversity of scientific findings.
Core Idea Diagram
Hypotheses
How it works
- Estimate between-study variance (heterogeneity) tau² using DerSimonian-Laird.
- Calculate random-effects weights: w = 1/(SE² + tau²).
- Compute pooled effect size as the weighted average of individual studies.
- Calculate pooled standard error as 1/sqrt(sum(w)) and construct 95% CIs.
Assumptions
Important Note
Random-effects meta-analysis assumes effect sizes vary across studies due to both sampling error and true heterogeneity (τ²). The model estimates both the mean effect (θ) and between-study variance. Prediction intervals (PI) indicate expected effect range in new studies, critical for assessing generalizability beyond the confidence interval for the mean.
Worked Example
| Study | FE Weight | RE Weight |
|---|---|---|
| Large Trial | 68.2% | 35.4% |
| Small Trial | 8.4% | 18.6% |
| RE Pooled | Diamond expands | |
Fixed vs. Random Weight Equalization
Increase the between-study variance τ2. Notice how random-effects weights become more uniform, giving small studies relatively more influence and broadening the pooled diamond.
Hypotheses
Pragmatic null and alternative hypotheses defined in mathematical notation.
H₀: θ = 0 (no pooled effect across studies; true effect is zero)
Hₐ: θ ≠ 0 (non-zero pooled effect; studies show consistent direction)
Random-effects meta-analysis assumes effect sizes vary across studies due to both sampling error and true heterogeneity (τ²). The model estimates both the mean effect (θ) and between-study variance. Prediction intervals (PI) indicate expected effect range in new studies, critical for assessing generalizability beyond the confidence interval for the mean.
Assumptions
The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.
Diagnostics
Checking residual plots and indices to examine model deviations and ensure standard error integrity.
- Forest plot showing individual study effects and pooled estimate with 95% CI
- Heterogeneity statistics: I² (%), τ², Cochran's Q with p-value
- 95% Prediction Interval (PI) for expected effect in new study - CRITICAL for generalizability
- Funnel plot and Egger's test for publication bias assessment
- Number of studies (k) and total sample size (N)
- Study weights visualization (bubble size in forest plot)
- Influence analysis (leave-one-out sensitivity showing impact of each study)
- Subgroup analysis or meta-regression to explain heterogeneity sources
- Comparison of τ² estimators (DL, REML, PM) for robustness
- Trim-and-fill or PET-PEESE adjusted estimates if publication bias detected
- Cumulative meta-analysis (chronological) to assess temporal trends
- Risk of bias summary for included studies
- Hartung-Knapp adjustment for CI (especially with k<20)
- Fail-safe N or Rosenthal's file-drawer to assess robustness to unpublished nulls
- P-curve or p-uniform analysis to assess evidential value
- Comparison with fixed-effect model to assess impact of heterogeneity
Applied Minds
Review concrete study examples, data layout guidelines, and copy executable syntax scripts.
Random-Effects with Prediction Interval
Research question: What is the pooled effect of cognitive-behavioral therapy (CBT) for major depression compared to control conditions, and how consistent are effects across diverse populations and settings? Design: Random-effects meta-analysis of k=15 randomized controlled trials (total N=1,847 participants) examining CBT vs. waitlist/usual care control. Outcome: Standardized mean difference (Hedges' g) in depression symptoms (Beck Depression Inventory or Hamilton Rating Scale) at post-treatment. This example demonstrates the critical importance of heterogeneity assessment and prediction intervals for clinical interpretation. The prediction interval reveals whether CBT effects generalize consistently across populations or vary substantially by context, directly informing evidence-based practice decisions. We assess publication bias, conduct influence analysis, and interpret findings within the broader context of depression treatment research.
# Random-Effects Meta-Analysis: CBT for Depression\n# Demonstrating prediction intervals and heterogeneity assessment\n\nlibrary(metafor) # rma() for random-effects meta-analysis\nlibrary(meta) # forest(), funnel() plotting\nlibrary(dplyr)\nlibrary(ggplot2)\n\n# === STEP 1: Simulate Meta-Analytic Dataset ===\n# In practice: data <- read.csv(\"meta_analysis_data.csv\")\n# Required columns: study_id, effect_size (Hedges' g), variance, n_treatment, n_control\n\nset.seed(2025)\nk <- 15 # Number of studies\n\n# Simulate effect sizes with heterogeneity\n# True effects vary: mean θ=0.70, between-study SD τ=0.20\ntrue_effects <- rnorm(k, mean=0.70, sd=0.20) # Random-effects: studies vary\n\n# Sample sizes vary across studies\nn_treat <- sample(40:100, k, replace=TRUE)\nn_control <- sample(40:100, k, replace=TRUE)\ntotal_n <- n_treat + n_control\n\n# Observed effect sizes (true effect + sampling error)\nsampling_se <- sqrt((n_treat + n_control)/(n_treat * n_control) + \n true_effects^2 / (2*(n_treat + n_control)))\nobserved_g <- rnorm(k, mean=true_effects, sd=sampling_se)\nvariance_g <- sampling_se^2\n\nmeta_data <- data.frame(\n study_id = paste0(\"Study_\", 1:k),\n author_year = paste0(LETTERS[1:k], \" et al. (20\", 10:24, \")\"),\n hedges_g = observed_g,\n variance = variance_g,\n se = sqrt(variance_g),\n n_treatment = n_treat,\n n_control = n_control,\n total_n = total_n\n)\n\nprint(\"=== Meta-Analytic Dataset ===")\nprint(meta_data)\n\n# === STEP 2: Random-Effects Meta-Analysis (REML) ===\n# REML (restricted maximum likelihood) preferred for τ² estimation\nre_model <- rma(yi = hedges_g, vi = variance, data = meta_data, \n method = \"REML\", slab = author_year)\n\nprint(\"\\n=== Random-Effects Meta-Analysis Results ===")\nprint(re_model)\n\n# Extract key statistics\npooled_g <- as.numeric(re_model$beta)\nci_lower <- re_model$ci.lb\nci_upper <- re_model$ci.ub\np_value <- re_model$pval\n\n# Heterogeneity statistics\ntau2 <- re_model$tau2 # Between-study variance\ntau <- sqrt(tau2) # Between-study SD\nI2 <- re_model$I2 # % variance due to heterogeneity\nH2 <- re_model$H2 # Ratio of total to sampling variance\nQ <- re_model$QE # Cochran's Q statistic\nQ_pval <- re_model$QEp # Q test p-value\n\ncat(\"\\n=== Pooled Effect ===")\ncat(\"\\nHedges' g =", round(pooled_g, 3))\ncat(\"\\n95% CI: [\", round(ci_lower, 3), \",\", round(ci_upper, 3), \"]\" )\ncat(\"\\np-value:\", format.pval(p_value, digits=3))\ncat(\"\\n\\n=== Heterogeneity Statistics ===")\ncat(\"\\nτ² (tau-squared) =", round(tau2, 4))\ncat(\"\\nτ (tau, between-study SD) =", round(tau, 3))\ncat(\"\\nI² =", round(I2, 1), \"%\")\ncat(\"\\nH² =", round(H2, 2))\ncat(\"\\nCochran's Q(\", re_model$k-1, \") =", round(Q, 2), \", p =", \n format.pval(Q_pval, digits=3))\n\nif (I2 < 25) {\n heterogeneity_interp <- \"low\"\n} else if (I2 < 50) {\n heterogeneity_interp <- \"moderate\"\n} else if (I2 < 75) {\n heterogeneity_interp <- \"substantial\"\n} else {\n heterogeneity_interp <- \"considerable\"\n}\ncat(\"\\nInterpretation: Heterogeneity is\", heterogeneity_interp)\n\n# === STEP 3: CRITICAL - Prediction Interval (PI) ===\n# PI estimates range of true effects in NEW studies (95% of future studies)\n# Formula: θ ± t(k-2) × √(τ² + SE²)\npi <- predict(re_model, digits=3)\n\ncat(\"\\n\\n=== 95% PREDICTION INTERVAL (CRITICAL) ===")\ncat(\"\\nPrediction Interval: [\", round(pi$pi.lb, 3), \",\", round(pi$pi.ub, 3), \"]\" )\ncat(\"\\n\\nInterpretation:\")\ncat(\"\\n- Confidence Interval (CI) [\", round(ci_lower, 2), \",\", round(ci_upper, 2),\n \"] = precision of MEAN effect estimate\")\ncat(\"\\n- Prediction Interval (PI) [\", round(pi$pi.lb, 2), \",\", round(pi$pi.ub, 2),\n \"] = expected range in NEW study\")\n\nif (pi$pi.lb > 0) {\n cat(\"\\n- PI excludes zero → Effects consistent across studies (good generalizability)\")\n} else if (pi$pi.ub < 0) {\n cat(\"\\n- PI excludes zero (negative) → Harmful effects consistent\")\n} else {\n cat(\"\\n- PI includes zero → Effects variable; some populations may show null/opposite effects\")\n cat(\"\\n (Limited generalizability; investigate moderators)\")\n}\n\n# === STEP 4: Forest Plot ===\npar(mar=c(5,4,2,2))\nforest(re_model, \n xlab = \"Hedges' g (CBT - Control)\",\n slab = meta_data$author_year,\n header = c(\"Study\", \"g [95% CI]\"),\n cex = 0.8,\n addpred = TRUE, # Add prediction interval to plot\n col = \"blue\",\n border = \"blue\",\n lwd = 2)\n\n# Add interpretation text\nmtext(paste0(\"Random-Effects Model: g = \", round(pooled_g, 2), \n \", 95% CI [\", round(ci_lower, 2), \", \", round(ci_upper, 2), \"]\"),\n side=3, line=0.5, cex=0.9, font=2)\nmtext(paste0(\"I² = \", round(I2, 1), \"% (\", heterogeneity_interp, \" heterogeneity); \",\n \"95% PI [\", round(pi$pi.lb, 2), \", \", round(pi$pi.ub, 2), \"]\"),\n side=3, line=-0.8, cex=0.8)\n\n# === STEP 5: Funnel Plot & Publication Bias ===\npar(mfrow=c(1,2))\n\n# Funnel plot\nfunnel(re_model, \n xlab = \"Hedges' g\",\n ylab = \"Standard Error\",\n main = \"Funnel Plot\",\n back = \"white\",\n shade = \"white\")\n\n# Egger's regression test for asymmetry\negger_test <- regtest(re_model, model=\"lm\")\ncat(\"\\n\\n=== Publication Bias Assessment ===")\ncat(\"\\nEgger's Regression Test:\")\ncat(\"\\n Intercept =", round(egger_test$zval, 3))\ncat(\"\\n p-value =", format.pval(egger_test$pval, digits=3))\nif (egger_test$pval < 0.10) {\n cat(\"\\n → Significant asymmetry detected (p<.10); publication bias possible\")\n} else {\n cat(\"\\n → No significant asymmetry (p≥.10); limited evidence of bias\")\n}\n\n# Trim-and-fill analysis (impute missing studies)\ntaf <- trimfill(re_model)\ncat(\"\\n\\nTrim-and-Fill Analysis:\")\ncat(\"\\n Imputed studies (k₀) =", taf$k0)\ncat(\"\\n Adjusted g =", round(as.numeric(taf$beta), 3))\ncat(\"\\n Adjusted 95% CI: [\", round(taf$ci.lb, 3), \",\", round(taf$ci.ub, 3), \"]\")\n\n# Funnel plot with trim-and-fill\nfunnel(taf, \n xlab = \"Hedges' g\",\n ylab = \"Standard Error\",\n main = \"Trim-and-Fill Adjusted\",\n back = \"white\",\n shade = \"white\",\n col = c(\"blue\", \"red\"))\nlegend(\"topright\", c(\"Observed\", \"Imputed\"), \n col=c(\"blue\", \"red\"), pch=19, cex=0.8)\n\npar(mfrow=c(1,1))\n\n# === STEP 6: Influence Analysis (Leave-One-Out Sensitivity) ===\ninfluence_results <- leave1out(re_model, digits=3)\n\ncat(\"\\n\\n=== Influence Analysis (Leave-One-Out) ===")\nprint(influence_results)\n\n# Plot influence\npar(mfrow=c(2,1), mar=c(4,4,2,2))\n\n# Effect size after removing each study\nplot(1:k, influence_results$estimate, \n ylim = range(c(influence_results$ci.lb, influence_results$ci.ub)),\n xlab = \"Study Removed\", ylab = \"Pooled g\",\n main = \"Influence Analysis: Effect Size\",\n pch = 19, col = \"blue\")\nabline(h = pooled_g, lty=2, col=\"red\", lwd=2)\nsegments(1:k, influence_results$ci.lb, 1:k, influence_results$ci.ub, col=\"blue\")\nlegend(\"topright\", \"Full model\", lty=2, col=\"red\", lwd=2, cex=0.8)\n\n# I² after removing each study\nplot(1:k, influence_results$I2, \n xlab = \"Study Removed\", ylab = \"I² (%)\",\n main = \"Influence Analysis: Heterogeneity (I²)\",\n pch = 19, col = \"darkgreen\")\nabline(h = I2, lty=2, col=\"red\", lwd=2)\n\npar(mfrow=c(1,1))\n\n# === STEP 7: Compare Fixed vs Random Effects ===\nfe_model <- rma(yi = hedges_g, vi = variance, data = meta_data, \n method = \"FE\", slab = author_year)\n\ncat(\"\\n\\n=== Comparison: Fixed vs Random Effects ===")\ncat(\"\\nFixed-Effect: g =", round(as.numeric(fe_model$beta), 3),\n \", 95% CI [\", round(fe_model$ci.lb, 3), \",\", round(fe_model$ci.ub, 3), \"]\")\ncat(\"\\nRandom-Effect: g =", round(pooled_g, 3),\n \", 95% CI [\", round(ci_lower, 3), \",\", round(ci_upper, 3), \"]\")\ncat(\"\\n\\nNote: Random-effects CI is wider (accounts for heterogeneity τ²)\")\nif (I2 > 50) {\n cat(\"\\n→ Random-effects model STRONGLY preferred (substantial heterogeneity)\")\n} else {\n cat(\"\\n→ Random-effects model preferred (generalizes beyond observed studies)\")\n}\n\n# === STEP 8: APA-Style Reporting ===\ncat(\"\\n\\n=== APA-STYLE REPORT ===")\ncat(\"\\nA random-effects meta-analysis of\", k, \"RCTs (N =", sum(total_n), \n \"participants) examined\\nCBT vs. control for major depression. The pooled effect was Hedges' g =",\n round(pooled_g, 2), \",\\n95% CI [\", round(ci_lower, 2), \",\", round(ci_upper, 2), \"], p <\", \n ifelse(p_value < 0.001, \".001\", format.pval(p_value, digits=2)),\n \", indicating a\\n\", ifelse(abs(pooled_g) < 0.5, \"small to medium\", \n ifelse(abs(pooled_g) < 0.8, \"medium to large\", \"large\")),\n \" effect favoring CBT.\\n\\nHeterogeneity was\", heterogeneity_interp, \"(I² =", round(I2, 1), \n \"%, τ² =", round(tau2, 3),\",\\nQ(\", re_model$k-1, \") =", round(Q, 2), \", p\", \n ifelse(Q_pval < 0.001, \" < .001\", paste0(\" = \", round(Q_pval, 3))), \").\\n\\nThe 95% prediction interval [\", round(pi$pi.lb, 2), \",\", round(pi$pi.ub, 2),\n \"] indicates that in a new\\nsimilar study, the true effect is expected to fall within this range.\")\n\nif (pi$pi.lb > 0) {\n cat(\" Since the\\nprediction interval excludes zero, CBT effects are expected to be consistently\\nbeneficial across diverse populations, supporting strong generalizability.\")\n} else {\n cat(\" Since the\\nprediction interval includes zero, effects may vary substantially across\\npopulations, with some contexts potentially showing minimal benefit. Moderator\\nanalysis is warranted to identify boundary conditions for CBT effectiveness.\")\n}\n\nif (egger_test$pval < 0.10) {\n cat(\"\\n\\nPublication bias assessment revealed funnel plot asymmetry (Egger's test p\", \n ifelse(egger_test$pval < 0.001, \"< .001\", \n paste0(\"= \", round(egger_test$pval, 3))),\n \"),\\nsuggesting potential small-study effects. Trim-and-fill analysis estimated\", \n taf$k0, \"missing\\nstudies, yielding an adjusted effect of g =", round(as.numeric(taf$beta), 2),\n \", 95% CI [\", round(taf$ci.lb, 2), \",\", round(taf$ci.ub, 2), \"],\\nwhich\", ifelse(abs(as.numeric(taf$beta)) > abs(pooled_g)*0.7, \n \" remains substantial\", \" is attenuated\"), \n \" compared to the unadjusted estimate.\")\n}\n\ncat(\"\\n\\nInfluence analysis (leave-one-out) indicated that no single study\\ndisproportionately influenced the pooled estimate (effect range:\", \n round(min(influence_results$estimate), 2), \"to\", \n round(max(influence_results$estimate), 2), \"), supporting robustness.\\n\")\n\ncat(\"\\nConclusion: CBT demonstrates a\", \n ifelse(abs(pooled_g) >= 0.8, \"large\", \"medium to large\"),\n \" pooled effect for depression, with\",\n heterogeneity_interp, \"heterogeneity.\\n\")\nif (pi$pi.lb > 0) {\n cat(\"The narrow prediction interval supports consistent benefits across settings.\\n\")\n} else {\n cat(\"However, the wide prediction interval suggests context-dependent effects,\\nlimiting generalizability. Future research should identify moderators\\n(e.g., depression severity, therapy format) to refine clinical recommendations.\\n\")\n}Pooled Hedges' g = 0.68, 95% CI [0.54, 0.82], p < .001. Large effect favoring CBT over control. Moderate heterogeneity (I² = 52%, τ² = 0.042) indicates meaningful variation across studies. CRITICAL: 95% Prediction Interval [0.29, 1.07] suggests that while the mean effect is large, individual studies vary from small-to-medium (0.29) to very large (1.07) effects. Since PI excludes zero, CBT benefits are expected consistently across populations, but magnitude varies. Egger's test non-significant (p = .34), limited publication bias. Influence analysis shows robustness (effect range 0.64-0.72 across leave-one-out). Conclusion: CBT produces substantial depression reduction on average, with context-dependent effect magnitude. Moderator analysis recommended to identify optimal implementation contexts.
Alternatives
Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.
- Prediction Interval Strike — Report the 95% PI to quantify the uncertainty of the *next* potential study result.
- Sensitivity Jackknife — Systematically remove studies one-by-one to find if a single outlier hijacks the mean.
- Fixed-Effects with Robust CIs — Use the Knapp-Hartung adjustment to protect significance in tiny RE study pools.
- Begg's Rank Audit — The robust rank-based alternative for asymmetric funnel diagnostics.
Post-hoc
Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.
Post-hoc pairwise tests defined for this model.
No specific guidelines provided.
Effect Size
Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.
Mean effect across population of studies. Interpret magnitude using Cohen's benchmarks (d: 0.2 small, 0.5 medium, 0.8 large) or field norms. Statistical significance (CI excludes zero) ≠ clinical importance.
Between-study variance (τ²) in squared units; τ (SD units) more interpretable. Large τ indicates substantial true heterogeneity. Compare τ to pooled effect: if θ=0.5, τ=0.3, effects range ~0.2-0.8.
% of total variability due to heterogeneity (not chance). <25% low, 25-50% moderate, 50-75% substantial, >75% considerable. High I² warrants moderator investigation. Sample-size dependent: imprecise with small k.
CRITICAL for generalizability. PI estimates range for true effect in new study. Wide PI = high heterogeneity, context-dependent effects. Narrow PI = consistent effects. If PI includes zero, some populations may show null/opposite effects.
0.2
0.5
0.8
Sample Size
Guidelines for minimum sample requirements and power analysis parameters.
The 'Stability Mandate': A minimum of 10 studies (k >= 10) is recommended to ensure the between-study variance (Tau-squared) is estimated with high-fidelity precision.
| Effect Size | Parameters | Required n |
|---|---|---|
| Small Effect | d=0.20 (Small, I²=50%) | Cumulative n ≈ 600 |
| Medium Effect | d=0.50 (Medium, I²=50%) | Cumulative n ≈ 120 |
| Large Effect | d=0.80 (Large, I²=50%) | Cumulative n ≈ 45 |
The 'Prediction Interval' Strike: Reporting only the 95% Confidence Interval is descriptive; calculating the 95% Prediction Interval is elite. The PI represents the uncertainty of the *next* study, often requiring k > 15 to reach statistical stability.
Reporting
How to compile statistical results into publication prose matching APA and journal style guides.
A random-effects meta-analysis of k studies (N = XXX participants) found a pooled effect of effect metric = X.XX (95% CI X.XX, X.XX, p < .XXX). Heterogeneity was low/moderate/substantial/considerable (I² = XX%, τ² = X.XX, Q(df) = XX.XX, p < .XXX). The 95% prediction interval X.XX, X.XX indicates that in a new study, the effect is expected to fall within this range, suggesting consistent/variable effects across populations. If applicable: Publication bias assessment via Egger's test showed [significant/non-significant asymmetry (p = .XXX), with/without evidence of small-study effects. Influence analysis confirmed robustness, with no single study disproportionately affecting the pooled estimate.]
- Number of studies (k) and total sample size (N)
- Pooled effect estimate with metric specified (e.g., Hedges' g, log OR)
- 95% Confidence Interval for pooled effect
- p-value for pooled effect
- Heterogeneity statistics: I² (%), τ², Cochran's Q(df) with p-value
- 95% Prediction Interval (CRITICAL - indicates expected range in new study)critical
- Publication bias assessment (Egger's test p-value, funnel plot description)
- Influence analysis summary (robustness check)
- Effect size interpretation (small/medium/large, contextualized)
- Generalizability assessment (based on PI width and heterogeneity)
Manuscript Lab
Copy standard summary tables and forensic reporting grids to outline analysis details.
| Metric | Estimate | 95% CI | z-score | p-value |
|---|---|---|---|---|
| Pooled Effect (SMD) | 0.45 | [0.32, 0.58] | 6.42 | < .001 |
| Heterogeneity (I²) | 42% | [15%, 65%] | — | .042 |
The 'Global Truth'. The average effect size across all studies, weighted by their precision (sample size).
The 'Consistency' Audit. Measures what percentage of variation between studies is real (due to different designs/populations) vs. random sampling error.
Command Center
Syntax libraries and function parameters for executing calculations in stats packages.
# 1. Execute Meta-Analysis (Hedges' g)
model <- meta::metacont(n.e, me.e, sd.e, n.c, me.c, sd.c,
data = df, sm = 'SMD', method.tau = 'REML')
summary(model)
# 2. Visualize Forest Plot
meta::forest(model)Heterogeneity is not a bug, it's a feature. If I² > 50%, do not just report the mean. Use 'Meta-Regression' to find the variable (e.g., age, dose) that is causing the differences.
# Execute Funnel Plot Audit (Publication Bias)
metafor::funnel(model)Common Mistakes
Analytical caveats and corrections to maintain modeling integrity.
References
Scholarly lineage and citation keys grounding the statistical framework.