All problems
Fixed vs Random Weights
Problem
Return [fixed_weights, random_weights] with fixed weights 1/se_i^2 and random weights 1/(se_i^2 + tau2) for the supplied between-study variance. Return [[], []] for empty input, a negative tau2, or any se <= 0.
Hint
Random-effects weights are always smaller than fixed-effect weights when tau2 > 0.
Test cases
case 1
in: [[0.1,0.2],0.01]
expected: [[99.99999999999999,24.999999999999996],[49.99999999999999,19.999999999999996]]
case 2
in: [[0.5],0]
expected: [[4],[4]]
case 3
in: [[],0.1]
expected: [[],[]]
case 4
in: [[0,0.1],0.1]
expected: [[],[]]
case 5
in: [[0.2,0.2,0.2],0.04]
expected: [[24.999999999999996,24.999999999999996,24.999999999999996],[12.499999999999998,12.499999999999998,12.499999999999998]]
Starter codePython
def fixed_vs_random_weights(sei, tau2):
# Your code here
pass5 test cases · run your code against them in the editor