Class NeweyWest
Why it matters here: an IC series computed on overlapping
h-bar forward returns is mechanically MA(h−1), and a
persistent signal (12-1 momentum, value, low volatility) adds positive
autocorrelation on top. The iid standard error s/√n then
understates the true one by roughly √((1+ρ)/(1−ρ)) for an AR(1)
with coefficient ρ: a factor of three at ρ = 0.8.
The long-run variance of a series x is estimated as
Ω = γ₀ + 2 Σ_{l=1..L} (1 − l/(L+1)) γ_l, γ_l = (1/n) Σ_t (x_t − x̄)(x_{t−l} − x̄)
and the standard error of the mean is √(Ω/n). The Bartlett
weights keep Ω non-negative. Note γ₀ uses the 1/n
divisor, so at L = 0 the result is s_pop/√n, slightly
below the sample-variance version for small n.
Lag choice: automaticLag(double[]) is the Andrews (1991, Econometrica
59(3), eq. 6.2 and Table I) AR(1) plug-in bandwidth for the Bartlett
kernel; lagFor(double[], int) combines it with the h − 1 floor that
overlapping h-bar windows require.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleautocorrelation(double[] x, int k) Lag-ksample autocorrelationγ_k / γ₀(0 for a constant series).static intautomaticLag(double[] x) Andrews (1991) AR(1) plug-in bandwidth for the Bartlett kernel:S = 1.1447 (α̂ n)^{1/3}withα̂ = 4ρ̂² / ((1−ρ̂)²(1+ρ̂)²), returned as an integer lagfloor(S)capped atn/2.static intlagFor(double[] x, int overlap) Lag for a series of statistics computed on overlappingoverlap-bar windows:max(overlap − 1, automaticLag(x)).static doublelongRunVariance(double[] x, int lag) HAC long-run variance Ω ofxwith Bartlett laglag.static doublestandardErrorOfMean(double[] x, int lag) HAC standard error of the sample mean ofx.static doubletStat(double[] x, int lag) HAC t-statistic of the mean against zero:mean / SE_HAC.
-
Method Details
-
longRunVariance
public static double longRunVariance(double[] x, int lag) HAC long-run variance Ω ofxwith Bartlett laglag. -
standardErrorOfMean
public static double standardErrorOfMean(double[] x, int lag) HAC standard error of the sample mean ofx. -
tStat
public static double tStat(double[] x, int lag) HAC t-statistic of the mean against zero:mean / SE_HAC. Zero for a constant series with zero mean; ±∞ for a constant non-zero series (no sampling variation at all). -
autocorrelation
public static double autocorrelation(double[] x, int k) Lag-ksample autocorrelationγ_k / γ₀(0 for a constant series). -
automaticLag
public static int automaticLag(double[] x) Andrews (1991) AR(1) plug-in bandwidth for the Bartlett kernel:S = 1.1447 (α̂ n)^{1/3}withα̂ = 4ρ̂² / ((1−ρ̂)²(1+ρ̂)²), returned as an integer lagfloor(S)capped atn/2.ρ̂is clamped to[−0.97, 0.97]so a near-unit-root series cannot request an unbounded window. -
lagFor
public static int lagFor(double[] x, int overlap) Lag for a series of statistics computed on overlappingoverlap-bar windows:max(overlap − 1, automaticLag(x)).
-