Skip to content
All library documents

Testing Mean Strategy Returns with Newey–West Standard Errors

Article Quant Q&A · Author: Good Guy Mike

Summary

The document explains how a t-statistic can test whether a trading strategy’s average return differs from a null value, commonly zero. A small statistic indicates insufficient evidence to reject the null of no excess return. Because return observations can exhibit serial dependence and changing variance, Newey–West standard errors adjust the estimated uncertainty for those features.

The answers provide MATLAB routines for estimating these standard errors, including a lag-length rule and a direct calculation for testing a sample mean against a specified null. The regression-based routine takes residuals and regressors; the simpler routine uses return autocovariances through a chosen lag. These are implementation examples rather than a full treatment of inference: results depend on the lag choice, assumptions, and correct handling of data and regression inputs. The document does not report an empirical strategy result or validate either implementation.

Key ideas

  • The t-statistic tests whether the observed mean return differs from a specified null, often zero.
  • Newey–West standard errors account for heteroscedasticity and serial correlation in the error process.
  • The document gives MATLAB approaches based on regression residuals or return autocovariances.
  • Lag length affects the estimate and can be selected by a rule or supplied directly.
  • The code examples are not accompanied by empirical validation or a detailed discussion of inference assumptions.

Tags

Full text
# t-statistics for the mean return, using Newey-West standard errors


# t-statistics for the mean return, using Newey-West standard errors












I have seen that in several papers, where the aim was to evaluate the performance of a certain investment strategy, they use t-statistics to test for significance in the results. However, this seems a bit odd to me as the t-statistics assumes that you have some theoretical mean that the observed mean deviates from, which is not being told in the article. The particular article I'm refering to is "Pairs Trading: Performance of a Relative-Value Arbitrage Rule", by Gatev et al. There are several others that use similar tests.

So my first question is what does these t-statistics tell them (or what is it that I do not understand)?

Furthermore, I wonder how the Newey-West standard error, as used in this manner, could be calculated in Matlab. As far as I have understood it there is no built in function to do this. After some googleing I could find a code, although it seemed to have several flaws (if I understood the conversation about it) so I guess it was not usable.

It seems like several similar questions have been asked before without success (https://stats.stackexchange.com/questions/43898/newey-west-t-statistics), hopefully I am a bit luckier this time!

Note: I am not sure if I am allowed to cross-post like this, I asked this question originally on stats.stackexchange without success. But as it concerns quant trading to some level I thought I might aswell try asking it here.

## Answer by lemarin (score 8)

https://quant.stackexchange.com/a/7733

In this case, the t-statistic is used to determine if the returns are statistically different from zero (the theoretical mean). A small t-statistic would imply that the null hypothesis (no significant excess return) cannot be rejected. Newey-West standard errors are used to correct for the correlations of error terms over time.

I have written a Matlab function to calculate Newey-West standard errors, with the option to have the lag length determined by the Newey-West (1994) plug-in procedure.

In order to use the code you will need to have your regression residuals matrix calculated.

```
function nwse = NeweyWest(e,X,L)
% PURPOSE: computes Newey-West adjusted heteroscedastic-serial
%          consistent standard errors
%---------------------------------------------------
% where: e = T x n vector of model residuals
%        X = T x k matrix of independant variables
%        L = lag length to use
%
%        se = Newey-West standard errors
%---------------------------------------------------

indexxx = sum(isnan(X),2)==0;
X = X(indexxx,:);
e = e(indexxx,:);

[N,k] = size(X);
k = k+1;
X = [ones(N,1),X];

if nargin < 3
% Newey-West (1994) plug-in procedure
L = floor(4*((N/100)^(2/9)));
end

Q = 0;
for l = 0:L
    w_l = 1-l/(L+1);
    for t = l+1:N
        if (l==0)   % This calculates the S_0 portion
            Q = Q  + e(t) ^2 * X(t, :)' * X(t,:);
        else        % This calculates the off-diagonal terms
            Q = Q + w_l * e(t) * e(t-l)* ...
                (X(t, :)' * X(t-l,:) + X(t-l, :)' * X(t,:));
        end
    end
end
Q = (1/(N-k)) .*Q;

nwse = sqrt(diag(N.*((X'*X)\Q/(X'*X))));

end
```

## Answer by user16458 (score 1)

https://quant.stackexchange.com/a/18204

I think that this code solves your problems. In your case h0 is zero while lag can be set equal to 6 (or 5)

function y=NWtest(ret,lag,h0)

```
T=size(ret,1);
vv=var(ret);

for l=1:1:lag

    cc=cov(ret(1:end-l),ret(l+1:end));
    vv=vv+2*(1-l/lag)*cc(1,2);
end

y=(mean(ret)-h0)/sqrt(vv)*sqrt(T);
```

end

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.