Signature
H = max(1, sqrt(Q / (k - 1))); SE_big = 0.5 * (log(max(Q, k)) - log(k - 1)) / (sqrt(2 * max(Q, k)) - sqrt(2 * k - 3)); SE_small = sqrt((1 - 1 / (3 * (k - 2)^2)) / (2 * (k - 2))); SE_lnH = (Q > k) * SE_big + (Q <= k) * SE_small; H_low = max(1, exp(log(H) - z * SE_lnH)); H_high = max(1, exp(log(H) + z * SE_lnH)); I2_low = (H_low^2 - 1) / H_low^2 * 100; I2_high = (H_high^2 - 1) / H_high^2 * 100
| Inputs | Definition | Unit |
|---|---|---|
Q | Cochran's heterogeneity statistic from HE-FM-ADMA-002, at least 0 | none |
k | Number of studies, at least 3 | count |
z | Standard normal multiplier, 1.96 for 95% limits | none |
H | Square root of Q over k-1, set to 1 when that root is below 1 | none, at least 1 |
|---|---|---|
SE_big | Value of the first case, evaluated at max(Q, k) and used only when Q is above k | none, on the natural log scale |
SE_small | Value of the second case, used when Q is at or below k; it depends on k only | none, on the natural log scale |
SE_lnH | Whichever of SE_big and SE_small applies | none, on the natural log scale |
H_low | Lower limit of H, not below 1 | none |
H_high | Upper limit of H, not below 1 | none |
I2_low | Lower limit of I-squared | percent, at least 0 |
I2_high | Upper limit of I-squared | percent, below 100 |
Function
Variance-based I-squared and test-based limits of H and I-squared in a meta-analysis
Maps the number of studies, the sums of their common-effect weights and a between-study variance from any estimator to a typical within-study variance and an I-squared, and maps Cochran's Q and the number of studies to H and to uncertainty limits for H and I-squared. Its inputs come from live records, Cochran's Q from HE-FM-ADMA-002 and the DerSimonian and Laird between-study variance from HE-FM-ADMA-004, and the point I-squared from Q is HE-FM-ADMA-003. The random-effects mean is HE-FM-ADMA-005 and the prediction interval that carries the article's argument for decision makers is HE-FM-ADMA-006, whose t multiplier HE-VR-ADMA-029 uses k-1 degrees of freedom; the k-2 variant in the article changes only that multiplier. Notation follows the Between-Study Heterogeneity article, with v_typ for its typical within-study variance.
Computational function
Computational function for Q, typical variance, I-squared and test-based limits from study estimates and variances
Takes a list of study estimates and variances and returns Q, the DerSimonian and Laird estimate, the typical within-study variance, I-squared by HE-FM-BSH-001 for that estimate and for an outside tau2, and the limits of HE-FM-BSH-002. Q and the estimate are the steps of HE-CF-ADMA-001, repeated here because the limits and v_typ need them; the pooled mean and its interval stay with HE-CF-ADMA-001. The calculator line writes out three studies, and any number of studies from three upward is in the Excel, R and Python code.
Inputs and outputs:
y_1toy_3are the study estimates andv_1tov_3their variances, as in HE-VR-ADMA-003 and HE-VR-ADMA-004;kis the number of studies,zthe normal multiplier andtau2_exta between-study variance from another estimator.w_1tow_3,W_1,W_2,theta_FandQare the weights, sums, common-effect estimate and Cochran's Q.tau2_DLis the HE-FM-ADMA-004 estimate,v_typthe typical variance,I2_DLandI2_extthe two percentages, andH,SE_big,SE_small,SE_lnH,H_low,H_high,I2_lowandI2_highare as in HE-FM-BSH-002.Assumption: The assumptions of HE-FM-BSH-001 and HE-FM-BSH-002 hold (HE-AS-BSH-001 to HE-AS-BSH-007). With fewer than three studies the R code stops with a message and the Python code raises AssertionError; a zero or negative variance does the same. Excel returns #DIV/0! for a blank or zero cell in StudyVar. When every estimate is equal, Q is 0 and the code returns H of 1, I-squared of 0 and the SE_small limits.
Worked example (Three illustrative trials): The estimates and variances of HE-EX-ADMA-003 with the restricted maximum likelihood tau2 of HE-EX-BSH-004.
y_1 = -0.6; y_2 = -0.05; y_3 = -0.4; v_1 = 0.04; v_2 = 0.01; v_3 = 0.0625; k = 3; z = 1.96; tau2_ext = 0.06577; w_1 = 25; w_2 = 100; w_3 = 16; W_1 = 141; W_2 = 10881; theta_F = -0.1872; Q = 6.867; tau2_DL = 0.07625; v_typ = 0.03133; I2_DL = 70.9; I2_ext = 67.7; H = 1.8530; SE_big = 0.3125; SE_small = 0.5774; SE_lnH = 0.3125; H_low = 1.0044; H_high = 3.4186; I2_low = 0.9; I2_high = 91.4Worked example (Identical estimates): Illustrative limiting case with every estimate at -0.2 and tau2_ext of 0.
y_1 = -0.2; y_2 = -0.2; y_3 = -0.2; v_1 = 0.04; v_2 = 0.01; v_3 = 0.0625; k = 3; z = 1.96; tau2_ext = 0; w_1 = 25; w_2 = 100; w_3 = 16; W_1 = 141; W_2 = 10881; theta_F = -0.2; Q = 0; tau2_DL = 0; v_typ = 0.03133; I2_DL = 0; I2_ext = 0; H = 1; SE_big = 0.2826; SE_small = 0.5774; SE_lnH = 0.5774; H_low = 1; H_high = 3.1006; I2_low = 0; I2_high = 89.6Excel: With estimates in a range named StudyEst and variances in StudyVar, enter
=COUNT(StudyEst)in NStudies,=SUMPRODUCT(1/StudyVar)in SumWeights,=SUMPRODUCT(1/StudyVar^2)in SumSqWeights,=SUMPRODUCT(StudyEst/StudyVar)/SumWeightsin PooledFE and=SUMPRODUCT((StudyEst-PooledFE)^2/StudyVar)in QStat. Enter=MAX(0,(QStat-(NStudies-1))/(SumWeights-SumSqWeights/SumWeights))in BetweenVarDL,=(NStudies-1)*SumWeights/(SumWeights^2-SumSqWeights)in TypicalVar,=BetweenVarDL/(BetweenVarDL+TypicalVar)*100in ISqDL and=BetweenVarExt/(BetweenVarExt+TypicalVar)*100in ISqExt. HStat, SELogH, HLimitLow, HLimitHigh, ISqLow and ISqHigh are as in HE-IM-BSH-002.R:
het <- function(y, v, tau2 = NULL, z = 1.96) { k <- length(y); if (k < 3) stop("at least 3 studies are needed"); if (any(v <= 0)) stop("variances must be above zero"); w <- 1 / v; W1 <- sum(w); W2 <- sum(w^2); Q <- sum(w * (y-sum(w * y) / W1)^2); tauDL <- max(0, (Q-(k-1)) / (W1-W2 / W1)); if (is.null(tau2)) tau2 <- tauDL; vt <- (k-1) * W1 / (W1^2-W2); H <- max(1, sqrt(Q / (k-1))); se <- if (Q > k) 0.5 * (log(Q)-log(k-1)) / (sqrt(2 * Q)-sqrt(2 * k-3)) else sqrt((1-1 / (3 * (k-2)^2)) / (2 * (k-2))); lim <- pmax(1, exp(log(H) + c(-1, 1) * z * se)); list(Q = Q, tauDL = tauDL, vt = vt, I2 = 100 * tau2 / (tau2 + vt), H = H, se = se, Hlim = lim, I2lim = 100 * (lim^2-1) / lim^2) }Called ashet(c(-0.6, -0.05, -0.4), c(0.04, 0.01, 0.0625), 0.06577)it returns Q of 6.867, tauDL of 0.07625, vt of 0.03133, I2 of 67.7, H of 1.853, Hlim of 1.004 and 3.419 and I2lim of 0.9 and 91.4.Python:
def het(y, v, tau2=None, z=1.96): k = len(y); assert k >= 3 and min(v) > 0, 'at least 3 studies and variances above zero are needed'; w = [1 / x for x in v]; W1 = sum(w); W2 = sum(a * a for a in w); m = sum(a * b for a, b in zip(w, y)) / W1; Q = sum(a * (b-m) ** 2 for a, b in zip(w, y)); dl = max(0, (Q-(k-1)) / (W1-W2 / W1)); t = dl if tau2 is None else tau2; vt = (k-1) * W1 / (W1 ** 2-W2); H = max(1, sqrt(Q / (k-1))); se = 0.5 * (log(Q)-log(k-1)) / (sqrt(2 * Q)-sqrt(2 * k-3)) if Q > k else sqrt((1-1 / (3 * (k-2) ** 2)) / (2 * (k-2))); lo = max(1, exp(log(H)-z * se)); hi = max(1, exp(log(H) + z * se)); return dict(Q=Q, tauDL=dl, vt=vt, I2=100 * t / (t + vt), H=H, se=se, Hlim=(lo, hi), I2lim=(100 * (lo * lo-1) / lo / lo, 100 * (hi * hi-1) / hi / hi))It needsfrom math import log, sqrt, exp, standard library only;het([-0.2, -0.2, -0.2], [0.04, 0.01, 0.0625])returns Q of about 0, H of 1 and Hlim of 1 and 3.101, andhet([1, 2], [0.1, 0.1])raises AssertionError.Test (Three illustrative trials): With the trials of the first worked example, QStat is 6.867, TypicalVar is 0.03133 and HLimitHigh is 3.419. Expected result TRUE. Doubling QStat gives 13.734, halving it 3.434, doubling HLimitHigh gives 6.837, halving it 1.709, and doubling TypicalVar gives 0.06267, all FALSE. Excel check
=AND(ABS(QStat-6.867)<0.001,ABS(TypicalVar-0.03133)<0.00001,ABS(HLimitHigh-3.419)<0.001)Test (Equality with the Q route): ISqDL is compared with the HE-IM-ADMA-003 expression on QStat, a different route. Expected result TRUE. With the first worked example, doubling ISqDL gives 141.8 and halving it 35.4, both FALSE. Excel check
=ABS(ISqDL-IF(QStat>NStudies-1,(QStat-(NStudies-1))/QStat*100,0))<1E-6Common error (Standard errors entered as variances): Entering 0.2, 0.1 and 0.25 in StudyVar gives Q of 1.096 in place of 6.867, an upper I-squared of 89.6% in place of 91.4%, and a v_typ of 0.1727 (computed here).
Common error (Random-effects weights in Q): Computing Q with the weights of HE-FM-MREG-002 at tau2 of 0.07625 gives 1.565 in place of 6.867, below its 2 degrees of freedom, so H is floored at 1 and the heterogeneity disappears from the statistic (computed here). HE-AS-ADMA-003 keeps the common-effect weights.
Source: Bowden J, Tierney JF, Copas AJ, Burdett S. Quantifying, displaying and accounting for heterogeneity in the meta-analysis of RCTs using standard and generalised Q statistics. BMC Medical Research Methodology. 2011;11:41. Sections Heterogeneity quantification using the standard Q-statistic and Reference intervals for the two I-squared statistics. Deeks JJ, Higgins JPT, Altman DG, McKenzie JE, Veroniki AA (editors). Chapter 10: Analysing data and undertaking meta-analyses (last updated November 2024). In: Higgins JPT, Thomas J, Chandler J, et al (editors). Cochrane Handbook for Systematic Reviews of Interventions version 6.5. Cochrane; 2024. Section 10.10.4.4. Villanueva EV, Zavarsek S. Evaluating heterogeneity in cumulative meta-analyses. BMC Medical Research Methodology. 2004;4:18. Equations 2 and 3. Dewey M. heterometa: convert various meta-analysis heterogeneity measures. R package version 0.5, 2026, CRAN.
w_1 = 1 / v_1; w_2 = 1 / v_2; w_3 = 1 / v_3; W_1 = w_1 + w_2 + w_3; W_2 = w_1^2 + w_2^2 + w_3^2; theta_F = (w_1 * y_1 + w_2 * y_2 + w_3 * y_3) / W_1; Q = w_1 * (y_1 - theta_F)^2 + w_2 * (y_2 - theta_F)^2 + w_3 * (y_3 - theta_F)^2; tau2_DL = max(0, (Q - (k - 1)) / (W_1 - W_2 / W_1)); v_typ = (k - 1) * W_1 / (W_1^2 - W_2); I2_DL = tau2_DL / (tau2_DL + v_typ) * 100; I2_ext = tau2_ext / (tau2_ext + v_typ) * 100; H = max(1, sqrt(Q / (k - 1))); SE_big = 0.5 * (log(max(Q, k)) - log(k - 1)) / (sqrt(2 * max(Q, k)) - sqrt(2 * k - 3)); SE_small = sqrt((1 - 1 / (3 * (k - 2)^2)) / (2 * (k - 2))); SE_lnH = (Q > k) * SE_big + (Q <= k) * SE_small; H_low = max(1, exp(log(H) - z * SE_lnH)); H_high = max(1, exp(log(H) + z * SE_lnH)); I2_low = (H_low^2 - 1) / H_low^2 * 100; I2_high = (H_high^2 - 1) / H_high^2 * 100
Try this function
Implementations
Excel
H, its standard error and the limits of H and I-squared in named cells
With Q in a cell named QStat, the number of studies in NStudies and the multiplier in ZCrit, the six formulas return, in order, cells named HStat, SELogH, HLimitLow, HLimitHigh, ISqLow and ISqHigh. IF evaluates only the selected case, so Excel needs no max(Q, k) term. A blank QStat is treated as 0 and gives HStat of 1 with SE_small; a blank NStudies returns #NUM! from the square root of a negative ratio.
=MAX(1,SQRT(QStat/(NStudies-1))); =IF(QStat>NStudies,0.5*(LN(QStat)-LN(NStudies-1))/(SQRT(2*QStat)-SQRT(2*NStudies-3)),SQRT((1-1/(3*(NStudies-2)^2))/(2*(NStudies-2)))); =MAX(1,EXP(LN(HStat)-ZCrit*SELogH)); =MAX(1,EXP(LN(HStat)+ZCrit*SELogH)); =(HLimitLow^2-1)/HLimitLow^2*100; =(HLimitHigh^2-1)/HLimitHigh^2*100
Assumptions
At least three studies and a Q from common-effect weights
Q uses the common-effect weights of HE-AS-ADMA-003. The heterometa documentation states that confidence intervals cannot be computed when k is 2. The calculator line divides by k-2 in SE_small and returns an error at k of 2 for any Q. Excel, whose IF evaluates only the case it selects, returns #DIV/0! at k of 2 when Q is at most 2, and a number when Q is above 2, which falls outside this formula's use.
Floor at one before the limits are set
H is set to 1 when Q is below k-1, since Villanueva and Zavarsek take the maximum of H and 1, and the limits are built around that floored value and floored again, as the heterometa code does. With Q of 14.4 and 24 studies the limits are therefore 1 and 1.34, matching the 1 and 1.34 held for the albumin example of Higgins and Thompson in the heterometa data set. Q of zero is allowed, since log(H) is then log(1).
Approximate limits with coverage that weakens at high I-squared
The limits rest on a normal approximation for the log of H. Bowden and colleagues found in their simulation that this reference interval appears to show sub-optimum coverage, most clearly when the true I-squared is large, and that intervals based on a generalised Q statistic appear to maintain the desired coverage. The limits are for a sense of the uncertainty and are not a test for choosing a pooling model (HE-ER-ADMA-003).
Jump in the standard error where the two cases meet
The two cases do not meet at Q equal to k. SE_big just above that point is 0.49 times SE_small at 3 studies and 0.66 times at 70 studies (derived), so limits for Q just above k are narrower than limits for Q just below it, and two meta-analyses with nearly equal Q can show visibly different intervals.
Worked examples
Limits for the three illustrative trials
Q of 6.867 from the three illustrative trials of HE-EX-ADMA-003. HE-EX-ADMA-004 gives the point I-squared of about 70.9%, and the limits show how little three trials fix it, about 0.9% and 91.4%.
Q = 6.867; k = 3; z = 1.96; H = 1.8530; SE_big = 0.3125; SE_small = 0.5774; SE_lnH = 0.3125; H_low = 1.0043; H_high = 3.4186; I2_low = 0.9; I2_high = 91.4
Three trials with Q of 130.3 in Higgins and Thompson
The gamma nail example of Higgins and Thompson as held in the heterometa data set, Q of 130.3 from 3 trials, for which the data set gives H of 8.07 with limits 6.08 and 10.72, and I-squared of 98% with limits 97% and 99%. The line reproduces those figures at the decimals held.
Q = 130.3; k = 3; z = 1.96; H = 8.0716; SE_big = 0.1449; SE_small = 0.5774; SE_lnH = 0.1449; H_low = 6.0758; H_high = 10.7228; I2_low = 97.3; I2_high = 99.1
Nineteen trials with Q of 81.5 in Higgins and Thompson
The sclerotherapy example of Higgins and Thompson as held in the heterometa data set, Q of 81.5 from 19 trials, for which the data set gives H of 2.13 with limits 1.71 and 2.64, and I-squared of 78% with limits 66% and 86%.
Q = 81.5; k = 19; z = 1.96; H = 2.1279; SE_big = 0.1102; SE_small = 0.1714; SE_lnH = 0.1102; H_low = 1.7144; H_high = 2.6410; I2_low = 66.0; I2_high = 85.7
Twenty-four trials with Q below its degrees of freedom
The albumin example of Higgins and Thompson as held in the heterometa data set, Q of 14.4 from 24 trials, for which the data set gives H of 1 with limits 1 and 1.34, and I-squared of 0% with limits 0% and 45%. Q is below k, so SE_small applies, and H is floored at 1. The upper limit here is 44.6%.
Q = 14.4; k = 24; z = 1.96; H = 1.0000; SE_big = 0.0967; SE_small = 0.1507; SE_lnH = 0.1507; H_low = 1.0000; H_high = 1.3436; I2_low = 0.0; I2_high = 44.6
Limiting case of Q equal to its degrees of freedom
Illustrative limiting case with 9 studies and Q of 8. The point I-squared of HE-FM-ADMA-003 is 0%, yet the upper limit is 64.8%, so a value of 0% from nine studies does not show that the studies share one effect.
Q = 8; k = 9; z = 1.96; H = 1.0000; SE_big = 0.1593; SE_small = 0.2664; SE_lnH = 0.2664; H_low = 1.0000; H_high = 1.6855; I2_low = 0.0; I2_high = 64.8
Common errors
Limits set around the unfloored H
With Q of 14.4 and 24 studies the raw root is 0.791. Building limits around it gives an upper H of 1.063 and an upper I-squared of 11.5% in place of 1.344 and 44.6%, which reads as firm evidence of homogeneity from a set of trials that the floored limits leave open.
First case of the standard error used for every Q
Applying the first case with Q itself in place of max(Q, k), at Q of 14.4 and 24 studies, gives 0.1745 in place of 0.1507 and an upper I-squared of 49.5% in place of 44.6%. At Q equal to k-1.5 its denominator is zero and Excel returns #DIV/0!.
Second case of the standard error written without the square
The last term in SE_small has (k-2)^2, as HE-SR-BSH-009 prints it. Writing 3 (k-2) instead gives 0.4564 in place of 0.4787 at 4 studies and an upper H of 2.45 in place of 2.56 when H is 1. The squared form agrees with the exact variance of the log of H under a central chi-squared distribution, one quarter of the trigamma function at (k-1)/2, with a difference in the variance of 0.0045 at 4 studies, 0.0002 at 6 and below 0.00001 at 11, against 0.0254 at 4 studies for the unsquared form (derived).
Quoting a single I-squared from few studies as a grade
Calling the 70.9% of HE-EX-ADMA-004 high heterogeneity ignores limits of about 0.9% and 91.4% from three trials. The Cochrane Handbook says simple thresholds should be avoided when studies are few, and the limits span its bands.
Sources
Higgins and Thompson on H and I-squared
Higgins JP, Thompson SG. Quantifying heterogeneity in a meta-analysis. Statistics in Medicine. 2002;21(11):1539-1558. Abstract, which describes H as the square root of the chi-squared heterogeneity statistic divided by its degrees of freedom and I-squared as a transformation of H, and says the paper discusses interval estimates and examines five example data sets.
Bowden and colleagues on reference intervals for I-squared
Bowden J, Tierney JF, Copas AJ, Burdett S. Quantifying, displaying and accounting for heterogeneity in the meta-analysis of RCTs using standard and generalised Q statistics. BMC Medical Research Methodology. 2011;11:41. Section Reference intervals for the two I-squared statistics, which says Higgins and Thompson recommend basing reference intervals for I-squared on the variance of the related H measure, using one of two formulae depending on Q relative to the number of trials, with a negative lower bound curtailed at zero. Results, subsection A simulation study, on sub-optimum coverage when the true I-squared is large.
Villanueva and Zavarsek printing the standard error of the log of H
Villanueva EV, Zavarsek S. Evaluating heterogeneity in cumulative meta-analyses. BMC Medical Research Methodology. 2004;4:18. Section Measures of heterogeneity, which, citing Higgins and Thompson 2002, prints equation 2 for the test-based standard error of the natural log of H, with one case for Q > k and one for Q <= k whose last term is 1/(3(k-2)^2), and equation 3 for the interval exp(ln(H) plus or minus Z SE[ln(H)]). It says the maximum of H and 1 is taken and that confidence intervals for I-squared follow from equations 2 and 3.
The heterometa R package code and example values
Dewey M. heterometa: convert various meta-analysis heterogeneity measures. R package version 0.5, 2026, CRAN. Function higgins, whose code computes H floored at 1, the two cases with (k-2)^2 and the floored limits, and data set dat.higgins02, which holds the values of the five examples from Higgins and Thompson 2002. The note to the data set records that the I-squared of 20 for the adjuvant chemotherapy example is almost certainly a typo for 29.
Rücker and colleagues printing H and I-squared limits
Rücker G, Schwarzer G, Carpenter JR, Schumacher M. Undue reliance on I2 in assessing heterogeneity may mislead. BMC Medical Research Methodology. 2008;8:79. Table 2, which prints for 70 trials Q of 85 with H of 1.11 and limits 1 and 1.29, and I-squared of 18.6% with limits 0% and 40.1%. The formula with the rounded Q of 85 gives 1.11, 1 and 1.29, and 18.8%, 0% and 40.3%.
Jackson and colleagues on the two forms of the standard error for H
Jackson D, Bowden J, Baker R. Approximate confidence intervals for moment-based estimators of the between-study variance in random effects meta-analysis. Research Synthesis Methods. 2015;6(4):372-382. Section A comparison with other approaches, which says Higgins and Thompson 2002, in their Appendix A2, suggested intervals for H squared using a standard error for its log and a normal approximation on that scale, and that they give two forms of the standard error, the one used depending on the value of H squared.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0
