<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=R_-_Forecasting_with_ARIMA</id>
	<title>R - Forecasting with ARIMA - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=R_-_Forecasting_with_ARIMA"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=R_-_Forecasting_with_ARIMA&amp;action=history"/>
	<updated>2026-05-13T23:42:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=R_-_Forecasting_with_ARIMA&amp;diff=24045&amp;oldid=prev</id>
		<title>Cesar Chew at 16:52, 25 November 2014</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=R_-_Forecasting_with_ARIMA&amp;diff=24045&amp;oldid=prev"/>
		<updated>2014-11-25T16:52:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cat|Forecasting}}&lt;br /&gt;
&lt;br /&gt;
== Moving Average ==&lt;br /&gt;
; Smoothing with Moving Average&lt;br /&gt;
&amp;lt;source lang = &amp;quot;rsplus&amp;quot;&amp;gt;&lt;br /&gt;
 plot(ma(rawdata$Price,order=2),type=&amp;quot;l&amp;quot;)&lt;br /&gt;
 lines(ma(rawdata$Price,order=4),type=&amp;quot;l&amp;quot;,col=&amp;quot;blue&amp;quot;)&lt;br /&gt;
 lines(ma(rawdata$Price,order=12),type=&amp;quot;l&amp;quot;,col=&amp;quot;red&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Autocorrelation Function ==&lt;br /&gt;
&amp;lt;source lang = &amp;quot;rsplus&amp;quot;&amp;gt;&lt;br /&gt;
 acf(rawdata$Price)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Seasonality ==&lt;br /&gt;
&amp;lt;source lang = &amp;quot;rsplus&amp;quot;&amp;gt;&lt;br /&gt;
 price.ts &amp;lt;- ts(rawdata$Price,frequency=12) &lt;br /&gt;
 seasonplot(price.ts)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Autoregression ==&lt;br /&gt;
&lt;br /&gt;
* AR(&amp;#039;&amp;#039;p&amp;#039;&amp;#039;) - autoregressive model of order &amp;#039;&amp;#039;p&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;lt;math&amp;gt;\varphi_1, \ldots, \varphi_p&amp;lt;/math&amp;gt;  -  &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;parameters&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; of the model&lt;br /&gt;
* &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; a constant &lt;br /&gt;
* &amp;lt;math&amp;gt;\varepsilon_t&amp;lt;/math&amp;gt;  white noise&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; X_t = c + \sum_{i=1}^p \varphi_i X_{t-i}+ \varepsilon_t \,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;rsplus&amp;quot;&amp;gt;&lt;br /&gt;
 rawdata &amp;lt;- read.table(&amp;quot;http://training-course-material.com/images/1/19/Sales-time-series.txt&amp;quot;,h=T)&lt;br /&gt;
 rawdata$Date &amp;lt;- as.Date(rawdata$Date)&lt;br /&gt;
&lt;br /&gt;
 plot(rawdata$Price,type=&amp;quot;l&amp;quot;,xlim=c(1,200))&lt;br /&gt;
&lt;br /&gt;
 # Build a model (try different methods)&lt;br /&gt;
 model &amp;lt;- ar(rawdata$Price)&lt;br /&gt;
&lt;br /&gt;
 # Predict&lt;br /&gt;
 pr = predict(model, n.ahead=100)&lt;br /&gt;
&lt;br /&gt;
 # add prediction to the plot&lt;br /&gt;
 lines(pr$pred,col=&amp;quot;red&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 # Increase the order&lt;br /&gt;
 model &amp;lt;- ar(rawdata$Price,order.max=40,aic=FALSE)&lt;br /&gt;
 pr = predict(model, n.ahead=100)&lt;br /&gt;
 lines(pr$pred,col=&amp;quot;blue&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 # Change the method&lt;br /&gt;
 model &amp;lt;- ar(rawdata$Price,order.max=40,aic=FALSE,method=&amp;quot;burg&amp;quot;)&lt;br /&gt;
 pr = predict(model, n.ahead=100)&lt;br /&gt;
 lines(pr$pred,col=&amp;quot;green&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* http://maths-people.anu.edu.au/~johnm/courses/r/ASC2008/pdf/Rtimeseries-ohp.pdf&lt;/div&gt;</summary>
		<author><name>Cesar Chew</name></author>
	</entry>
</feed>