Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-305

Weak Instrument F-Statistic

Problem

Return the first-stage F statistic for a single instrument: R^2/((1 - R^2)/(n - 2)) from regressing treatment on instrument with an intercept. Return 0.0 when n < 3, the treatment has no variance, or the fit is perfect.

Hint

A rule of thumb is that F above 10 signals a strong instrument.

Test cases

case 1
in: [[1,2,3,4,5],[2,4,5,4,5]]
expected: 4.500000000000002
case 2
in: [[1,2,3,4],[1,2,3,4]]
expected: 0
case 3
in: [[1,1,2,2],[1,3,2,4]]
expected: 0.4999999999999999
case 4
in: [[1,2],[1,2]]
expected: 0
case 5
in: [[1,2,3],[5,5,5]]
expected: 0
Starter codePython
def weak_instrument_f(instrument, treatment):
    # Your code here
    pass

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