ft=zeros(1000,1);
gt=zeros(1000,1);
FT=zeros(1000,1) ;
Gt=zeros(1000,1) ;
CovXY=zeros(length(X)-999,1) ;
VarX=zeros(length(X)-999,1) ;
VarY=zeros(length(X)-999,1) ;
rho=zeros(1,length(X)-999) ;
x=zeros(1000,1) ;
y=zeros(1000,1);
for j=1:length(X)-999
x=X(j :j+999);
y=Y(j :j+999) ;
[parameters, ll, Ft, VCV, scores] = garchpq(x,1,1) ;
clear parameters ll VCV scores
[parameters, ll, Gt, VCV, scores] = garchpq(y,1,1) ;
clear parameters ll VCV scores
for k=1 :1000
ft(k)=x(k)/sqrt(Ft(k));
gt(k)=y(k)/sqrt(Gt(k)) ;
end
[CovXY(j, :),VarX(j, :),VarY(j, :)]=DCCA(ft,gt,n);
rho(j)=CovXY(j)/(VarX(j)*VarY(j)) ;
end
end