BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hussier1
Fluorite | Level 6

I ran a cross-correlation analysis using PROC TIMESERIES, and found a correlation of 0.51695 at a lag of 1. I wanted to then find the associated significance level, so I created a new data set with the appropriate lag and applied PROC CORR, which gave me 0.52006. I also tested the correlation w/o any lag and both gave me exactly 0.1460650864, so I presume it's an error somewhere with the lagging. I looked at the outputted datasets however, and it all seems to be in order. The difference is pretty minor, but should I be concerned?sas1.PNG

 

proc timeseries data=final2 crossplots=ccf outcrosscorr=final3;
id weeks interval=day accumulate=none;
var ncresiduals gtresiduals;
run;


data final4;
set final2;
gt3=lag(gtresiduals);
run;

proc corr pearson data=final4 out=final5;
var gt3;
with ncresiduals;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
MichaelL_SAS
SAS Employee

The formulas on the documentation page you provided explain why you are not getting the same values when there is a lag. Note that in the cross covariance formula it is always the mean of y that is being used regardless of the lag value. In your example code the variables gtresiduals (y) and gt3 (the lagged values you created) will (very likely) have different means. As @PaigeMiller said the two procedures are computing different quantities.  

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

PROC TIMESERIES (as far as I know), does not compute correlations, it computes auto-correlations, and so this should not be the same as PROC CORR which does computer correlations.

--
Paige Miller
hussier1
Fluorite | Level 6
I based my code on this : https://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_timeseries_se..., and the graphical output is marked "cross-correlation" on top, so I don't think that's the issue.
PaigeMiller
Diamond | Level 26

Cross correlations from PROC TIMESERIES are not the same as CORRELATIONS from PROC CORR. I don't think they should match.

--
Paige Miller
hussier1
Fluorite | Level 6
If they're done at the same lag, shouldn't they? They match for lag zero, and did match when I did something similar with a different dataset.
MichaelL_SAS
SAS Employee

The formulas on the documentation page you provided explain why you are not getting the same values when there is a lag. Note that in the cross covariance formula it is always the mean of y that is being used regardless of the lag value. In your example code the variables gtresiduals (y) and gt3 (the lagged values you created) will (very likely) have different means. As @PaigeMiller said the two procedures are computing different quantities.  

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 808 views
  • 2 likes
  • 3 in conversation