Solved – Robust OLS standard errors (Newey-West)

autocorrelationheteroscedasticityleast squaresMATLABneweywest

I am running a simple OLS regression with HAC adjustment (i.e. Heteroschedasticity and Autocorrelation adjustment) using the following function in hac() in matlab.

My regression is simple in that I am regressing against a vector of ones only:

$Y = \alpha + \epsilon$

In Matlab, the implementation is as follows (this is only to show how it is implemented, but the variables are not the true ones I use in my real example):

Y = rand(500,1);
X = ones(500, 1);  
hac(X, Y, 'intercept', false, 'weights','BT','display','full')

However, for my real variable Y, I get the error that matrix is not positive definite. I am not sure why that would be at all, since I am regressing against one variable only, which is constant 1!

On the other hand, when I run a simple OLS, then there is no error. Something must be happening when the HAC adjustment is done.

Any help would be appreciated. Thank you!

Best Answer

Is it possible that the "meat" of your sandwich is 0 because you include all residuals in HAC with equal weights?

That is, if that is case, in

$\hat V= n(X'X)^{-1}(X'\hat\Omega X)(X'X)^{-1}$

we have that

$$nX'\hat\Omega X = \left(\sum_t\hat u_t\right)^2,$$

which is zero by the FOC of OLS $\sum_t\hat u_t=0$ when, as is the case here, the regression has a constant.