Skip to content
DeepForgeby svx
All problems
HardStatisticsst-138

Newey-West Lite Standard Error

Problem

Return the Newey-West standard error of the mean with one lag: sqrt((gamma0 + 2*gamma1)/n), where gamma0 and gamma1 are the lag-0 and lag-1 autocovariances with denominator n. Return 0.0 when n < 2, the series is constant, or the long-run variance is negative.

Hint

The lag correction accounts for serial correlation.

Test cases

case 1
in: [[1,2,3,4,5]]
expected: 0.848528137423857
case 2
in: [[1,-1,1,-1,1]]
expected: 0
case 3
in: [[3,3]]
expected: 0
case 4
in: [[1,2]]
expected: 0
case 5
in: [[2,4,6,8]]
expected: 1.3693063937629153
Starter codePython
def newey_west_lite_se(data):
    # Your code here
    pass

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