# 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 (http://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.

-

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

-
Thanks, this is a lot more then I hoped for! I'm still a bit confused about the error terms. Since our hypothesis is that the returns are zero, would that imply that the error terms (they are equivalent with the model residuals, isn't it?) are simply the returns? If I use the article as an example, the result would be a T x n vetor of the returns from altering the strategy n times/ways. Should e (as def in your code) be the T x n vector, or should the s.e. be evaluated separately for each vector of return. Also, what would X be? – Good Guy Mike Apr 13 '13 at 18:32
Ok I think I understand the purpose of using the Newey-West s.e. now. Since they evaluate the performance over a 6 month period and then only rolls forward 1 month, the returns will be correlated, hence this has to be adjusted for. The lag 6 is because the return "today" is correlated with those 6 (shouldnt it be 5?) month backwards. Is this correct? However, I am still confused about the input in the matlab code. I would really appreciate if someone could explain it (the questions in my previous comment) to me! – Good Guy Mike Apr 15 '13 at 14:14
T x n makes it useful for correcting several series at a time, you should treat it as T x 1 for all practical purposes with the residuals being for all independent variables considered at the same time. Excess returns would simply be the "α" (mean/intercept) term in a regression, but the model in your paper probably considers a range of other factors (β's). – lemarin Apr 15 '13 at 17:26
Reply to the 2nd comment: yes the Newey-West standard errors are used to correct for autocorrelation in the computation of the t-statistic, which uses the estimated standard errors as the denominator. In your case, the t-stat is simply (mean-0)/(std.error). – lemarin Apr 15 '13 at 17:28
Ok, thank you! Maybe you just gave the article a quick glance so you can't answer this. But do you know if the choice of the lag (6) is arbitrary or is it because the strategy is tested over a 6 month period, but just pushed forward 1 month every time (when backtesting it). In other words each month is traded 6 times. – Good Guy Mike Apr 15 '13 at 17:38

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

-