Time Series

ARIMA Time Series Modeling

26 Feb , 2015  

<br />



Forecasting based on ARIMA (autoregressive integrated moving averages) models, commonly know as the Box–Jenkins approach, comprises following stages:

i.) Model identification ii.) Parameter estimation

iii.) Diagnostic checking

These stages are repeated until a “suitable” model for the given data has been identified (e.g. for prediction). The following three sections show some facilities that R offers for assisting the three stages in the Box–Jenkins approach.

A first step in analyzing time series is to examine the autocorrelations (ACF) and partial autocorrelations (PACF). R provides the functions acf( ) and pacf( ) for computing and plotting of ACF and PACF. The order of “pure” AR and MA processes can be identified from the ACF and PACF as shown below:

      acf(sim.ar,main="ACF of AR(2) process")
      acf(sim.ma,main="ACF of MA(2) process")
      pacf(sim.ar,main="PACF of AR(2) process")
      pacf(sim.ma,main="PACF of MA(2) process")

plot of chunk unnamed-chunk-1

The function arima.sim( ) was used to simulate ARIMA(p,d,q)–models ; in the first line 1000 observations of an ARIMA(2,0,0)–model (i.e. AR(2)–model) were simulated and saved as sim.ar. Equivalently, the second line simulated 1000 observations from a MA(2)–model and saved them to sim.ma.

An useful command for graphical displays is par(mfrow=c(h,v)) which splits the graphics window into (h×v) regions — in this case we have set up 4 seperate regions within the graphics window.(The last four lines created the ACF and PACF plots of the two simulated pro- cesses. Note that by default the plots include confidence intervals (based on uncorrelated series).

Parameter–Estimation of ARIMA–Models

Once the order of the ARIMA(p,d,q)–model has been specified, the function arima( ) from the ts–library can be used to estimate the parameters:


Here, fit is a list containing e.g. the coefficients (fitcoef),residuals(fitresiduals) and the Akaike Information Criterion AIC (fit$aic).

Diagnostic Checking

A first step in diagnostic checking of fitted models is to analyze the residuals from the fit for any signs of non–randomness. R has the function tsdiag( ), which produces a diagnostic plot of a fitted time series model:


plot of chunk unnamed-chunk-3

##  Box-Pierce test
## data:  fit$residuals
## X-squared = 0.0021, df = 1, p-value = 0.9631

The Box–Pierce (and Ljung–Box) test examines the Null of independently dis- tributed residuals. It’s derived from the idea that the residuals of a “correctly specified” model are independently distributed. If the residuals are not, then they come from a miss–specified model. The function Box.test( ) computes the test statistic for a given lag.

Prediction of ARIMA–Models

Once a model has been identified and its parameters have been estimated, one purpose is to predict future values of a time series. Lets assume, that we are satisfied with the fit of an ARIMA(1,0,1)–model to the LakeHuron–data:

As with Exponential Smoothing, the function predict( ) can be used for pre- dicting future values of the levels under the model:



plot of chunk unnamed-chunk-4

Here we have predicted the levels of Lake Huron for the next 8 years (i.e. until 1980). In this case, LH.pred is a list containing two entries, the predicted values LH.predpredandthestandarderrorsofthepredictionLH.predse. Using a rule of thumb for an approximate confidence interval (95%) of the prediction, “prediction ± 2·SE”, one can e.g. plot the Lake Huron data, predicted values and an approximate confidence interval.

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *