Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-205

Tau-Squared and I-Squared

Problem

Return [tau2, I2] for a set of effect sizes and standard errors: tau2 is the DerSimonian-Laird estimate max(0, (Q - (k-1))/(sum(w) - sum(w^2)/sum(w))) and I2 = max(0, (Q - (k-1))/Q)*100 with Q the fixed-effect Cochran statistic. Return [0.0, 0.0] when fewer than two studies are given, any se <= 0, or the denominator is not positive.

Hint

I-squared is the share of total variability due to between-study heterogeneity.

Test cases

case 1
in: [[1,1.2],[0.1,0.1]]
expected: [0.009999999999999986,49.999999999999964]
case 2
in: [[0.5,0.5,0.5],[0.1,0.2,0.3]]
expected: [0,0]
case 3
in: [[0.5,0.3,0.7],[0.1,0.2,0.15]]
expected: [0.007241379310344817,25.609756097560947]
case 4
in: [[1,1.5],[0.1,0.2]]
expected: [0.1,80]
case 5
in: [[1],[0.1]]
expected: [0,0]
Starter codePython
def tau_i_squared(yi, sei):
    # Your code here
    pass

5 test cases · run your code against them in the editor