Free AI web copilot to create summaries, insights and extended knowledge, download it at here
2241
Abstract
e"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*aG18qFd9qvZ8mn2LO3go5Q.png"><figcaption></figcaption></figure><p id="c3d9">For the ACV (autocovariance), consider the lag h=0 (i.e. the variance)</p><figure id="9de0"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*M8eq_VHR7nNAIRVrC_raFQ.png"><figcaption></figcaption></figure><p id="152b">Solving for the ACV(0), we have that</p><figure id="c91d"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Ow-OyZ8G9l-HxIEJx_dgKA.png"><figcaption></figcaption></figure><p id="77f5">When h is not 0, it follows that</p><figure id="349d"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*Kz4ZJ1J4_0clkGHAC2yQsw.png"><figcaption></figcaption></figure><p id="eb6d">Note that sometimes we are using “+h” and others, “-h”. These are equivalent; we will see later that the ACV function is <b>symmetric</b>, that is, ACV(h)=ACV(-h). Plugging back what we had before,</p><figure id="cc2f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*5-QHHzoSvEFoT2Vb92TXjQ.png"><figcaption></figcaption></figure><p id="67d0">What a cool formula! Further, you can verify using the definition that the <b>autocorrelation</b> is given by</p><figure id="83e4"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*oCPz8VWxm-Ri4D_UH2mt8g.png"><figcaption></figcaption></figure><p id="f2a0">Notice something? If the absolute value of phi is more than 1, the correlation will only become worse as the lag increases! Contrarily, this tells us that if phi is less than 1 in absolute value, the autocorrelation will <b>decrease exponentially</b> the further the lag.</p><p id="1c0f"><b>How to R</b></p><p id="0382">Let’s simulate some AR(1) data with phi=0.7 X:</p>
<figure id="1fcf">
<div>
<div>
<iframe class="gist-iframe" src="/gist/JairParra/b9c0eb5e68105406ff3ae67137f54d8e.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><p id="27f9">First, we set up the true AR(1) coefficient to 0.7, then we compressed this into a <code>list</code> object. We
Options
set <code>ma=NULL</code> because we want to create an AR(1) process. Then, we pass this to the<code>arima.sim</code> function to generate 600 observations using the model. We can now inspect both the data plot and the ACF plot as follows:</p>
<figure id="673d">
<div>
<div>
<iframe class="gist-iframe" src="/gist/JairParra/7ef55d91f32aaab7d46325ca084c7a48.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><figure id="2f21"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*iQNCAE5C9KQyOy_2o2BB4g.png"><figcaption></figcaption></figure><figure id="1a52"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*EnqZaJFoEFZHVQ0hzOzJUw.png"><figcaption></figcaption></figure><p id="8c35">We can see that the process is indeed mean zero, and that the ACF decreases exponentially in h. Although it appears to increase a bit at lags 10 and 25, it mostly stays within the bounds.</p><h2 id="7335">Next time</h2><p id="5e87">We will continue next time with another important process: the <a href="https://medium.com/@hair.parra/a-complete-introduction-to-time-series-analysis-with-r-stationary-processesiv-21bb484d8148"><b>moving average MA(1)</b></a> process, along with its expectation, ACV function and cool R visualizations like these ones :)</p><h2 id="5be5">Previous article</h2><p id="23d0"><a href="https://medium.com/@hair.parra/a-complete-introduction-to-time-series-analysis-with-r-stationary-processesii-e0f66d10051a">Stationary Processes II</a></p><h2 id="d0a5">Main page</h2><p id="0cf2"><a href="https://readmedium.com/a-complete-introduction-to-time-series-analysis-with-r-9882f2d44c9d">https://readmedium.com/a-complete-introduction-to-time-series-analysis-with-r-9882f2d44c9d</a></p><h2 id="2f49">Follow me at</h2><ol><li><a href="https://www.linkedin.com/in/hair-parra-526ba19b/">https://www.linkedin.com/in/hair-parra-526ba19b/</a></li><li><a href="https://github.com/JairParra">https://github.com/JairParra</a></li><li><a href="https://medium.com/@hair.parra">https://medium.com/@hair.parra</a></li></ol></article></body>