Skip to content
DeepForgeby svx
All problems
HardStatisticsst-357

Newey West Bartlett Factors

Problem

The Newey-West long-run variance factor is 1 + 2 * sum_{k=1}^{L} (1 - k / (L + 1)) * rho_k, where rho_k are sample autocorrelations and L the lag truncation.

Given the autocorrelation list (rho_1 upward) and L, return the factor.

Hint

Bartlett weights decay linearly with the lag.

Test cases

case 1
in: [[0.5],1]
expected: 1.5
case 2
in: [[0.5,0.25],2]
expected: 1.8333333333333335
case 3
in: [[0,0,0],3]
expected: 1
Starter codePython
def newey_west_bartlett_factors(autocorrelations, lags):
    # Your code here
    pass

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