function [resultat,t,p]=momentum(index,J,L)
% -----------------------------------------------------------------
% Elaborated by : BEN HASSEN Anis
% "Institut Suprieur de Gestion de Tunis" (ISG Tunis)
% University of Tunis
% 41, rue de la Libert - Cit Bouchoucha - C.P. : 2000 Le Bardo
% Tunisia
% University e-mail: http://www.isg.rnu.tn/
% Personal e-mail: benhassenanis@yahoo.com
% _________________________________________________________________
% January 14, 2004.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output:
% resultat: average daily return of momentum strategy applied on a portfolio of
% securities with a ranking period J and a holding period L
% t: t-statistic of the difference between winners and losers
% p: p-value under the null Hypothesis that the return of the momentum
% strategy is equal to zero.
%******************************************************************
% Input:
% index: a time series matrix (prices Pt) with column variables and row
% observations
% J: Ranking period
% L: Holding period
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tps=cputime;
rt1=diff(log(index));
s=size(index);
T=s(1)-1;
for i=1:s(2),
rtJ(:,i)=rkp(rt1(:,i),J)';
rtL(:,i)=rkp(rt1(:,i),L)';
end
if J==1,
rtJ=rt1;
end
if L==1,
rtL=rt1;
end
for i=1:T-J+1,
[x,TRI(:,i)]=sortrows(rtJ(i,:)');
end
TRI=TRI';
TRI=TRI(1:T-J-L+1,[1,2,3,s(2)-2,s(2)-1,s(2)]);
rtL=rtL(J+1:T-L+1,:);
for i=1:T-J-L+1,
aux=rtL(i,:);
res(i,:)=aux(TRI(i,:));
end
r=mean(res);
Winner=mean(res(:,[4 5 6])');
Loser=mean(res(:,[1 2 3])');
resultat=mean(r(4:6))-mean(r(1:3));
[t,p]=ttest3(Winner-Loser);
tps=cputime-tps