Signature
theta_R = sum_(i=1)^k [y_i / (v_i + tau2)] / sum_(i=1)^k [1 / (v_i + tau2)]; SE_R = sqrt(1 / sum_(i=1)^k [1 / (v_i + tau2)])
| Inputs | Definition | Unit |
|---|---|---|
y_i | Effect estimate of study i on the pooling scale | the chosen effect scale |
v_i | Variance of y_i within study i | squared units of the effect scale |
tau2 | Estimated between-study variance, for example from the DerSimonian and Laird formula | squared units of the effect scale |
theta_R | Estimated mean of the distribution of true study effects | the chosen effect scale |
|---|---|---|
SE_R | Standard error of theta_R, treating tau2 as known | the chosen effect scale |
kNumber of studies pooled (count)
Function
Inverse-variance pooling of aggregate study-level effect estimates
Maps the effect estimate and its variance from each of k studies to one pooled estimate, its standard error and measures of between-study heterogeneity. Each study is weighted by the inverse of the variance of its estimate, so more precise studies count for more. Under a common-effect model the weight uses the within-study variance alone; under a random-effects model it also includes the between-study variance tau2. In health technology assessment the pooled relative effect, usually a log hazard ratio or log odds ratio, is then applied to a baseline from another source in a decision model.
Computational function
Computational function: DerSimonian and Laird meta-analysis from study estimates and standard errors
Takes the two columns an aggregate data synthesis starts from, each study's effect estimate and its standard error, and returns the full DerSimonian and Laird analysis in one pass: the common-effect estimate and standard error (HE-FM-ADMA-001), Cochran's Q (HE-FM-ADMA-002), I-squared (HE-FM-ADMA-003), tau2 (HE-FM-ADMA-004) and the random-effects mean, standard error and 95% confidence interval (HE-FM-ADMA-005). The inputs differ from the formulae's variables: the formulae take variances and previously computed statistics, while the function squares the standard errors itself and each step uses the vector or statistic produced by the step before.
Inputs and outputs:
y: Vector of study effect estimates on the pooling scale, for example log hazard ratios; required, at least two studies. Unit: the chosen effect scale.;se: Vector of the standard errors of y, in the same order; required, all above zero. Unit: the chosen effect scale.;theta_F: Common-effect pooled estimate. Unit: the chosen effect scale.;SE_F: Standard error of theta_F. Unit: the chosen effect scale.;Q: Cochran's statistic. Unit: none.;I2: I-squared. Unit: percent.;tau2: DerSimonian and Laird between-study variance. Unit: squared units of the effect scale.;theta_R: Random-effects pooled mean. Unit: the chosen effect scale.;SE_R: Standard error of theta_R. Unit: the chosen effect scale.;CI_low_R,CI_high_R: 95% confidence limits of theta_R, exponentiated for a ratio measure. Unit: the chosen effect scale.Assumption: Each estimate is approximately normal on the pooling scale with a known variance equal to the square of its standard error, and the studies estimate different but related effects. I-squared is returned as 0 when Q does not exceed k-1, which also avoids a division by zero when Q is 0. The confidence interval uses 1.96 and treats tau2 as known; the prediction interval in HE-FM-ADMA-006 needs a t quantile.
Worked example (Three illustrative trials from the article): Log hazard ratios of -0.60, -0.05 and -0.40 with standard errors of 0.20, 0.10 and 0.25 give a common-effect hazard ratio of 0.829 and a random-effects hazard ratio of 0.730 with a 95% confidence interval of 0.502 to 1.062.
y = (-0.60, -0.05, -0.40); se = (0.20, 0.10, 0.25); theta_F = -0.1872; SE_F = 0.0842; Q = 6.867; I2 = 70.9; tau2 = 0.07625; theta_R = -0.3147; SE_R = 0.1910; CI_low_R = -0.6891; CI_high_R = 0.0597Worked example (Two consistent trials where random effects collapses to common effect): Two trials with log hazard ratios of -0.30 and -0.20 and equal standard errors of 0.10 give a Q of 0.5, below its 1 degree of freedom, so tau2 and I-squared are 0 and the random-effects result equals the common-effect one. This limiting case checks the truncation.
y = (-0.30, -0.20); se = (0.10, 0.10); theta_F = -0.25; SE_F = 0.0707; Q = 0.5; I2 = 0; tau2 = 0; theta_R = -0.25; SE_R = 0.0707Excel:
=SUMPRODUCT(B2:B4/C2:C4^2)/SUMPRODUCT(1/C2:C4^2)in F2,=SQRT(1/SUMPRODUCT(1/C2:C4^2))in F3,=SUMPRODUCT((B2:B4-F2)^2/C2:C4^2)in F4,=IF(F4>COUNT(B2:B4)-1,(F4-(COUNT(B2:B4)-1))/F4*100,0)in F5,=MAX(0,(F4-(COUNT(B2:B4)-1))/(SUMPRODUCT(1/C2:C4^2)-SUMPRODUCT(1/C2:C4^4)/SUMPRODUCT(1/C2:C4^2)))in F6,=SUMPRODUCT(B2:B4/(C2:C4^2+F6))/SUMPRODUCT(1/(C2:C4^2+F6))in F7,=SQRT(1/SUMPRODUCT(1/(C2:C4^2+F6)))in F8,=F7-1.96*F8in F9 and=F7+1.96*F8in F10. With one study per row, estimates in B2:B4 and standard errors in C2:C4, cells F2 to F10 return theta_F, SE_F, Q, I2, tau2, theta_R, SE_R and the two confidence limits; extending the ranges adds studies.R:
dl_meta <- function(y, se) { v <- se^2; w <- 1/v; k <- length(y); th_f <- sum(w*y)/sum(w); q <- sum(w*(y-th_f)^2); i2 <- if (q > k-1) 100*(q-(k-1))/q else 0; tau2 <- max(0, (q-(k-1))/(sum(w)-sum(w^2)/sum(w))); ws <- 1/(v+tau2); th_r <- sum(ws*y)/sum(ws); se_r <- sqrt(1/sum(ws)); c(theta_F = th_f, SE_F = sqrt(1/sum(w)), Q = q, I2 = i2, tau2 = tau2, theta_R = th_r, SE_R = se_r, CI_low_R = th_r-1.96*se_r, CI_high_R = th_r+1.96*se_r) }Vectorised over studies;dl_meta(c(-0.60, -0.05, -0.40), c(0.20, 0.10, 0.25))reproduces the article's example, and exp() of the estimates and limits gives hazard ratios.Python:
def dl_meta(y, se): v = [s**2 for s in se]; w = [1/x for x in v]; k = len(y); sw = sum(w); th_f = sum(a*b for a, b in zip(w, y))/sw; q = sum(a*(b-th_f)**2 for a, b in zip(w, y)); i2 = 100*(q-(k-1))/q if q > k-1 else 0.0; tau2 = max(0.0, (q-(k-1))/(sw-sum(a*a for a in w)/sw)); ws = [1/(x+tau2) for x in v]; th_r = sum(a*b for a, b in zip(ws, y))/sum(ws); se_r = math.sqrt(1/sum(ws)); return th_f, math.sqrt(1/sw), q, i2, tau2, th_r, se_r, th_r-1.96*se_r, th_r+1.96*se_rUses the math module and plain lists, and returns the nine outputs in the order listed above.Test (Random-effects standard error at least the common-effect one): Because tau2 is never negative, SE_R is never below SE_F. Expected result: TRUE. Excel check:
=F8>=F3Test (Zero tau2 returns the common-effect result): When tau2 is 0, as in the two-trial example, the random-effects mean equals the common-effect estimate. Expected result: TRUE. Excel check:
=IF(F6=0,ABS(F7-F2)<1E-12,TRUE)Common error (Entering hazard ratios instead of log hazard ratios): Entering the hazard ratios 0.549, 0.951 and 0.670 with the log-scale standard errors mixes two scales. In the three-trial example the function then returns I-squared of about 47% instead of 70.9% and tau2 of about 0.028 instead of 0.07625, and exponentiating the pooled value of about 0.848 suggests a hazard ratio of about 2.3, that is harm. Ratio measures enter as natural logarithms and the outputs are exponentiated afterwards.
Source: Veroniki AA, Jackson D, Viechtbauer W, et al. Methods to estimate the between-study variance and its uncertainty in meta-analysis. Research Synthesis Methods. 2016;7(1):55-79. Section on the DerSimonian and Laird estimator, which gives Q with common-effect weights and the truncated moment estimate of tau2; the method is from DerSimonian R, Laird N. Controlled Clinical Trials. 1986;7(3):177-188.
v = se^2; w = 1 / v; theta_F = sum(w * y) / sum(w); SE_F = sqrt(1 / sum(w)); Q = sum(w * (y - theta_F)^2); I2 = max(0, (Q - (k - 1)) / Q) * 100; tau2 = max(0, (Q - (k - 1)) / (sum(w) - sum(w^2) / sum(w))); theta_R = sum(y / (v + tau2)) / sum(1 / (v + tau2)); SE_R = sqrt(1 / sum(1 / (v + tau2))); CI_low_R = theta_R - 1.96 * SE_R; CI_high_R = theta_R + 1.96 * SE_R
Try this function
Implementations
Excel
Random-effects pooled mean and standard error from two ranges
With the ranges StudyEst and StudyVar and the between-study variance in a cell named BetweenVar, the first formula returns theta_R and the second SE_R.
=SUMPRODUCT(StudyEst/(StudyVar+BetweenVar))/SUMPRODUCT(1/(StudyVar+BetweenVar)); =SQRT(1/SUMPRODUCT(1/(StudyVar+BetweenVar)))
Assumptions
Different but related true effects across studies
The studies estimate different, yet related, effects whose spread is summarised by tau2, usually with normally distributed true effects. The pooled value is their mean, not the effect in any one setting.
Between-study variance plugged in as known
SE_R treats tau2 as fixed, so it does not reflect the uncertainty in tau2 itself, which the Cochrane Handbook describes as large when studies are few.
Worked examples
Random-effects pooled log hazard ratio of three illustrative trials
Adding a tau2 of 0.07625 to each variance gives weights of 8.602, 11.594 and 7.207, summing to 27.404. The pooled mean log hazard ratio is about -0.3147 with a standard error of about 0.1910, a hazard ratio of 0.730 with a 95% confidence interval of 0.502 to 1.062, as in the article.
k = 3; y_i = [-0.60,-0.05,-0.40]; v_i = [0.04,0.01,0.0625]; tau2 = 0.07625; theta_R = -0.3147; SE_R = 0.1910
Random-effects pooling with zero between-study variance
With tau2 equal to 0 the random-effects weights equal the common-effect weights, and the result is the common-effect estimate of about -0.1872 with a standard error of about 0.0842.
k = 3; y_i = [-0.60,-0.05,-0.40]; v_i = [0.04,0.01,0.0625]; tau2 = 0; theta_R = -0.1872; SE_R = 0.0842
Common errors
Taking the random-effects mean as automatically the better model input
Random-effects pooling gives relatively more weight to smaller studies. In the three-trial example the largest trial falls from 70.9% of the weight to 42.3%, and the mean moves towards the larger effects of the two smaller trials. If small studies report larger effects because of small-study bias, the shift reflects bias rather than true variation, so the choice between the two estimates belongs in a scenario analysis.
Sources
Random-effects inverse-variance method in the Cochrane Handbook
Deeks JJ, Higgins JPT, Altman DG, McKenzie JE, Veroniki AA (editors). Chapter 10: Analysing data and undertaking meta-analyses. In: Cochrane Handbook for Systematic Reviews of Interventions version 6.5. Cochrane; 2024. Section 10.3.2 and section 10.10.4 (study variances adjusted to incorporate the between-study variance Tau2) and section 10.10.4.1 (relatively more weight to smaller studies under random effects).
DerSimonian and Laird random-effects weights
DerSimonian R, Laird N. Meta-analysis in clinical trials. Controlled Clinical Trials. 1986;7(3):177-188. Random-effects weighted estimate of the mean treatment effect using the within-study and estimated between-study variances.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0