All problems
Granger-lite Predictability Flag
Problem
Test whether lagged x improves the prediction of y beyond lagged y alone. Fit two OLS regressions on t = 1, ..., n-1: the restricted model y[t] = a + b * y[t-1] and the unrestricted model y[t] = a + b * y[t-1] + c * x[t-1], then compare their residual sums of squares.
Return True when the unrestricted SSE is smaller than the restricted SSE by more than 1e-9, otherwise False. Return False when fewer than three points are available.
Hint
Solve the normal equations with Gaussian elimination for one and two regressors.
Test cases
case 1
in: [[1,2,3,4,5,6],[0,1,2,3,4,5]]
expected: false
case 2
in: [[0,1,3,2,5,4],[1,3,2,5,4,7]]
expected: true
case 3
in: [[0,1,0,1,0,1],[1,2,3,4,5,6]]
expected: false
case 4
in: [[1,3,2,4,3,5],[1,2,3,4,5,6]]
expected: true
Starter codePython
def granger_lite(y, x):
# Your code here
pass4 test cases · run your code against them in the editor