Skip to content
DeepForgeby svx
All problems
HardTime Seriests-084

Granger F-Statistic Small

Problem

Compute the F statistic comparing restricted and unrestricted regressions: F = ((SSE_r - SSE_u) / q) / (SSE_u / (n_obs - n_params)), where q is the number of restrictions.

Return 0.0 when SSE_u is 0, q is not positive, or the unrestricted degrees of freedom are not positive.

Hint

A large F means the restrictions substantially worsen the fit.

Test cases

case 1
in: [10,5,1,20,3]
expected: 17
case 2
in: [12,10,1,30,3]
expected: 5.4
case 3
in: [10,10,1,20,3]
expected: 0
case 4
in: [8,4,2,25,4]
expected: 10.5
Starter codePython
def granger_f(sse_r, sse_u, q, n_obs, n_params):
    # Your code here
    pass

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