# Newey-West (1987) t-stats

I have a time-series which is autocorrelated by construction. I have calculated the sample mean of this time-series, and would like to calculate the t-statistic corresponding to the hypothesis that the mean of this time-series is zero. It is my understanding that since my time-series is autocorrelated and possibly heteroscedastic, that I must use a t-statistic "adjusted for serial dependence according to the Newey-West method".

1. I have problem understanding the method, and how to implement this in Python. As far as I understand, Newey-West is used in regressions to obtain HAC standard errors, since the OLS standard errors are not a reliable basis for inference under serial correlation of the error term in a regression. But in my case, I am not regressing anything, so how does the Newey-West method fit in? I would have simply divided the sample mean (minus 0) by the standard error (sample standard deviation over square root of the number of observations). There would therefore be no need for regressing anything.
2. How can I implement computation of Newey-West t-statistics in Python?

A trick is to regress your variable of interest, say $$X$$, on a vector of ones. In R it would be lm(X~1); probably something similar in Python. Then use HAC standard errors to test the hypothesis that the intercept of the model is equal to zero.
Alternatively, do a $$t$$-test using a robust standard error which is the square root of the long-run variance of $$X$$ obtained using Newey-West or some other autocorrelation-robust estimator.