numeraire.newey_west_lrv#

numeraire.newey_west_lrv(x: NDArray[float64], lags: int = 0, valid: NDArray[bool] | None = None) float[source]#

Bartlett-kernel long-run variance of a 1-D series (lags=0 = plain variance, MLE).

lrv = g0 + 2 * sum_{l=1..lags} (1 - l/(lags+1)) * g_l with g_l the lag-l autocovariance (denominator T).

valid (optional, same shape as x) marks which positions are observed. When given, the mean and every autocovariance use only the observed values, and lag-l pairs are formed from observations exactly l positions apart on the original axis (with n = the number of observed positions). This keeps HAC lags meaningful for a series with internal gaps — compacting the gaps away would treat observations several periods apart as adjacent. The default (None) is the dense behavior: every position observed.