Skip to content
DeepForgeby svx
All problems
HardTime Seriests-284

ADF t-Statistic Lite

Problem

Compute the Dickey-Fuller t-statistic for a series by regressing the first differences on the lagged level with an intercept: dy[t] = a + b * y[t-1]. Return t = b / se(b), where se(b) = sqrt(SSE / ((m - 2) * Sxx)) and m is the number of differences.

Return 0.0 when there are fewer than four observations or the regression is degenerate (zero Sxx or zero standard error).

Hint

A deterministic linear series leaves no residual variance, so the t-statistic is defined as 0.

Test cases

case 1
in: [[1,2,3,4,5,6,7,8]]
expected: 0
case 2
in: [[2,1,3,2,4,3,5,4]]
expected: -1.6598500055174643
case 3
in: [[1,2,3]]
expected: 0
case 4
in: [[10,11,13,12,15,14,16,17]]
expected: -0.8451542547285166
case 5
in: [[3,1,4,1,5,9,2,6]]
expected: -2.5885640954239317
Starter codePython
def adf_t_statistic(series):
    # Your code here
    pass

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