Use ASTSA and ARIMA for time series prediction

Today we will use R astsa (Applied Statistical Time Series Analysis) library to analyze data and predict it with ARIMA model.

Load the data

Look at ACF and PACF

Compare auto correlation and partial autocorrelation functions for diff data

Output:

sber-acf2

The ACF spikes are inside boundaries, it shows low auto correlation. Maybe ARIMA will not be a perfect model for that. Let’s look at first lags on PACF – only lag 1 spike is relatively big, so will use order 1 for ar (1,0,0) or ma (0,0,1).

Forecast

We need to choose (p,d,q) orders, where:
p – AR order
d– difference order
q – MA order

Let’s try Auto Regression model. PACF already showed us that only order 1 coefficients matter, so p = 1. We analyzing diff data, so d = 1. We don’t worry about MA in this example, so q = 0. Our (p,d,q) will be (1,1,0).

R code will be:

Output:

sber-sarima-for

Where:
Black
– original data
Red
  – prediction
Dark gray – 1 RMS prediction or 68% percentile
Light gray – 2 RMS prediction or 95 percentile.

Looks like a  very broad prediction, so we need to try another model.

 

Leave a Reply

Your email address will not be published.