<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Question about ACF plot in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423534#M22294</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Autocorrelation calculation is different from pearson correlation coefficient. Below is the formula for autocorrelation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://docs.oracle.com/cd/E17236_01/epm.1112/cb_statistical/images/graphics/pred_autocorrelation.gif" border="0" alt="Image result for autocorrelation formula" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input a b;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2&lt;BR /&gt;2 3&lt;BR /&gt;3 4&lt;BR /&gt;4 5&lt;BR /&gt;5 6&lt;BR /&gt;6 7&lt;BR /&gt;7 8&lt;BR /&gt;8 9&lt;BR /&gt;9 10&lt;BR /&gt;10 .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select mean(a) into :average from test;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set test;&lt;BR /&gt;a1 = (a-&amp;amp;average);&lt;BR /&gt;a2 = (b-&amp;amp;average);&lt;BR /&gt;a3 = a1*a2;&lt;BR /&gt;a4 = (a-&amp;amp;average)**2;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=want sum;&lt;BR /&gt;var a1 a2 a3 a4;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;r1 =&amp;nbsp; sum(a3)/sum(a4) = 0.7&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Dec 2017 01:52:54 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2017-12-26T01:52:54Z</dc:date>
    <item>
      <title>Question about ACF plot</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423501#M22291</link>
      <description>&lt;P&gt;I have a quick question about how the&amp;nbsp;autocorrelation is computed in the ACF plot and I'm hoping someone can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this simple data set:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input a b;
datalines;
1 .
2 1
3 2
4 3
5 4
6 5
7 6
8 7
9 8
10 9
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Basically, the test data has variable A and B. Variable B has the lagged value of A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to calculate the autocorrelation of A at lag 1. I read that, by definition, the autocorrelation of A at lag 1 is just the correlation of A with&amp;nbsp;its own lagged value (which is B).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I did a Proc Corr on A and B:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc corr data=test;
var a b;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This gets me the correlation of 1 which makes perfect sense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="temp1.png" style="width: 454px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17524i617AC50EB91F7A9A/image-size/large?v=v2&amp;amp;px=999" role="button" title="temp1.png" alt="temp1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then plot the ACF plot for A using Proc Timeseries:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc timeseries data=test plots=acf;
var a;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I looked at the second bar in the plot which shows the autocorrelation at lag 1 and it is showing something close to 0.7 instead:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="temp 2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17525iFA781F54A894B056/image-size/large?v=v2&amp;amp;px=999" role="button" title="temp 2.png" alt="temp 2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I doing the plot incorrectly? How come the ACF plot show an autocorrelation of 0.7 when it should be just 1?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Dec 2017 08:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423501#M22291</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-12-25T08:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Question about ACF plot</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423516#M22292</link>
      <description>&lt;P&gt;this could approach your result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input a b;
datalines;
1 .
2 1
3 2
4 3
5 4
6 5
7 6
8 7
9 8
10 9
;
run;
proc reg data=test;
model b=a/noint;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Dec 2017 15:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423516#M22292</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-25T15:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Question about ACF plot</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423530#M22293</link>
      <description>&lt;P&gt;Hi I ran your code but I don't seem to get the right answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is that I think the autocorrelation between A and B is 1 because B is just a lagged value of A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, on the ACF plot, the autocorrelation at lag 1 is showing something close to 0.7:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="temp 3.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17526i31E2D88E0272585C/image-size/large?v=v2&amp;amp;px=999" role="button" title="temp 3.png" alt="temp 3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I have some misunderstanding on the definition of autocorrelation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 00:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423530#M22293</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-12-26T00:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Question about ACF plot</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423534#M22294</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Autocorrelation calculation is different from pearson correlation coefficient. Below is the formula for autocorrelation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://docs.oracle.com/cd/E17236_01/epm.1112/cb_statistical/images/graphics/pred_autocorrelation.gif" border="0" alt="Image result for autocorrelation formula" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input a b;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2&lt;BR /&gt;2 3&lt;BR /&gt;3 4&lt;BR /&gt;4 5&lt;BR /&gt;5 6&lt;BR /&gt;6 7&lt;BR /&gt;7 8&lt;BR /&gt;8 9&lt;BR /&gt;9 10&lt;BR /&gt;10 .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select mean(a) into :average from test;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set test;&lt;BR /&gt;a1 = (a-&amp;amp;average);&lt;BR /&gt;a2 = (b-&amp;amp;average);&lt;BR /&gt;a3 = a1*a2;&lt;BR /&gt;a4 = (a-&amp;amp;average)**2;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=want sum;&lt;BR /&gt;var a1 a2 a3 a4;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;r1 =&amp;nbsp; sum(a3)/sum(a4) = 0.7&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 01:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Question-about-ACF-plot/m-p/423534#M22294</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-12-26T01:52:54Z</dc:date>
    </item>
  </channel>
</rss>

