All problems
Weak Instrument F
Problem
Compute the first-stage F statistic for a weak instrument: with R^2 the squared Pearson correlation between z and x, F = R^2 * (n - 2) / (1 - R^2).
Return 0.0 when n < 3, a variance is 0, or |r| is 1.
Hint
Rule of thumb: first-stage F below 10 signals a weak instrument.
Test cases
case 1
in: [[1,2,3,4],[2,4,6,8]]
expected: 0
case 2
in: [[1,2,3,4],[1,3,2,5]]
expected: 4.481481481481476
case 3
in: [[1,1,1],[1,2,3]]
expected: 0
case 4
in: [[1,2],[1,2]]
expected: 0
Starter codePython
def weak_instrument_f(z, x):
# Your code here
pass4 test cases · run your code against them in the editor