Skip to content

BUG: combine_effects DerSimonian-Laird tau2 not truncated at zero #10520

Closed

Description

@Jason10191019999

Describe the bug

combine_effects(method_re='dl') in statsmodels/stats/meta_analysis.py does not truncate the DerSimonian-Laird tau^2 estimate at zero:

tau2 = (q - df) / c

For nearly homogeneous studies the raw estimate is negative, which produces nonsense random-effects results: the combined mean can fall outside the range of the study effects, and for other inputs var_eff_w_re becomes negative and the standard deviation is NaN. The published DL estimator (DerSimonian & Laird 1986) and R metafor truncate tau^2 at zero, as does this module's own Paule-Mandel path (_fit_tau_iter_mm uses max(0, tau2_new)). The one-step moment estimator _fit_tau_mm has the same issue.

Reproducer

import numpy as np
from statsmodels.stats.meta_analysis import combine_effects

eff = np.array([0.30, 0.32, 0.28, 0.31])
var = np.array([0.04, 0.09, 0.05, 0.06])
res = combine_effects(eff, var, method_re="dl")
print(res.tau2)           # -0.0561 (negative)
print(res.mean_effect_re) # 0.4000, outside [0.28, 0.32]

Expected behavior

tau2 = np.maximum(0, (q - df) / c). With truncation, tau^2 = 0 here and the random-effects results coincide with the fixed-effects results (mean 0.2955, within the range of the effects), consistent with R metafor (rma(yi, vi, method="DL") returns tau^2 = 0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions