Skip to content
DeepForgeby svx
All problems
HardML Fundamentalsml-202

Regression Discontinuity Jump

Problem

Estimate the regression discontinuity jump at cutoff. Fit separate least-squares lines to points with cutoff - bandwidth <= x < cutoff and cutoff <= x <= cutoff + bandwidth, then return the difference of the fitted values at cutoff.

Return 0.0 if either side has fewer than two points or zero x-variance.

Hint

The jump is the gap between the right and left fitted lines evaluated at the cutoff.

Test cases

case 1
in: [[0,1,2,3,4,5],[1,3,5,11,13,15],3,2]
expected: 4
case 2
in: [[0,1,2,3,4,5],[1,3,5,11,13,15],3,3]
expected: 4
case 3
in: [[0,1,2],[0,1,2],2,1]
expected: 0
case 4
in: [[],[],1,1]
expected: 0
Starter codePython
def rd_jump(X, y, cutoff, bandwidth):
    # Your code here
    pass

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