Thank you again, SAScom1, for the clarifications. I've gone through the manual check-in procedure. Borrowing some codes from the SAS Guides, I generated series for Xt and Yt.
I apologize if the code below isn't very efficient, but I hope it gets the job done. In the final table (CFF_Final_Check), I present the "answers" (CORR_1 and CORR_2)—that is, the CCFs obtained using both the manual and automatic methods. They appear to be close in value, but not identical.
I may be making a mistake at some stage, which could explain the discrepancy. Could you please take a look? Thank you!
proc iml;
phi = {1 -0.5};
theta = {1 0.8};
Ytseries = armasim(phi, theta, 125, 1, 100, -1234321);
create Yt from Ytseries[colname={'Yt'}];
append from Ytseries;
quit;
data test;
Xt = 100;
nl = 0; al = 0;
do i = 1 to 100;
a = rannor(12345);
n = 0.75 * nl + 0.5 * al + a;
al = a;
nl = n;
z = n + 1;
Xt = Xt + z;
date = intnx('month', '1jan1988'd, i-1);
format date monyy.;
output;
end;
drop nl al i a n z;
run;
data test_new;
retain date Xt;
set test;
run;
data final;
merge test_new yt;
dXt=dif(Xt);
run;
proc sql noprint;
select mean(Yt) into :meanYt from final;
select mean(dXt) into :meandXt from final where dXt is not missing;
quit;
proc arima data=final;
identify var=xt(1) noprint;
estimate p=1 q=1 method=ml outest=A noprint;
run;
quit;
data _null_;
set A(obs=1);
call symputx('ARxt', AR1_1);
call symputx('MAxt',MA1_1);
run;
data final;
set final;
cYt=Yt-&meanYt;
cdXt=dXt-&meandXt;
run;
proc print data=final;
run;
proc arima data=final(firstobs=2);
identify var=cdXt noprint;
estimate p=1 q=1 noconstant ar = &ARxt ma = &MAxt noest method=ml noprint;
forecast out = outx(keep = residual) lead = 0;
run;
quit;
proc arima data=final;
identify var=cYt noprint;
estimate p=1 q=1 noconstant ar = &ARxt ma = &MAxt noest method=ml noprint;
forecast out = outy(keep = residual) lead = 0;
run;
quit;
data outx;
set outx;
residual_x = residual;
drop residual;
run;
data outy;
set outy;
if _N_ = 1 then delete;
residual_y = residual;
drop residual;
run;
data B;
do i=1 to 99;
date = intnx('month','1Feb1988'd,i-1);
format date monyy.;
output;
end;
drop i;
run;
data CCF;
merge B outY outX;
run;
proc arima;
identify var=residual_y crosscorr=residual_x outcov=CCF_1;
run;
quit;
proc arima data=final;
identify var=Xt(1) noprint;
estimate p=1 q=1 noprint;
identify var=Yt crosscorr=Xt(1) outcov=CCF_2;
run;
quit;
data CCF_1;
set ccf_1;
CORR_1=corr;
drop lag var crossvar N cov stderr invcorr partcorr corr;
run;
data CCF_2;
set ccf_2;
CORR_2=corr;
drop corr var crossvar N cov stderr invcorr partcorr;
run;
data CFF_Final_Check;
merge CCF_2 CCF_1;
if _N_ <= 26 then delete;
run;
... View more