Truncating an autocovariance sum with equal weights can produce a negative variance estimate – a structural problem, not a rounding one. The Bartlett taper is the Fourier transform of a non-negative kernel, so the estimator is positive semi-definite by construction.
References
Newey, W. K. & West, K. D. (1987). Econometrica 55:703-708; Bartlett, M. S. (1950) Biometrika 37:1-16.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Bartkw(V)
#> $w
#> [1] 0.8888889 0.7777778 0.6666667 0.5555556 0.4444444 0.3333333 0.2222222
#> [8] 0.1111111
#>
#> $estimate
#> [1] 4
#>
#> $M
#> [1] 8
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Bartlett kernel lag weights"
#>
#> attr(,"class")
#> [1] "morie_rich_result" "list"
