# How to predict time series data with ARIMA

I'm a beginner in data analysis field and I wanna try to predict time series data using ARIMA model but I still don't understand some of the concept.

I've read some papers about ARIMA and this model -> ARIMA(p,d,q) seems to be the general model.

And this equation seems to be the general forecasting equation:

ŷt   =   μ + ϕ1 yt-1 +…+ ϕp yt-p - θ1et-1 -…- θqet-q


What I want to ask is, what is p, d and q? And how do I fit them in the above equation?

For example, if I want to predict stock market and have data like this:

Price       Open        High        Low
5,900.85    5,855.08    5,907.44    5,851.70
5,841.05    5,860.55    5,866.61    5,839.59
5,863.03    5,872.59    5,873.03    5,841.02
5,863.96    5,897.01    5,904.95    5,859.85
5,894.61    5,910.16    5,918.09    5,882.94


Which attribute is p, d and q and how do I use those data in above equation?

Thanks

The data you provided is not enough to fit an arima model since the smaple size may less then number of variables, so let's consider the time series dataset from package tseries in R:

# install this package if you need:install.packages('tseries')
library(tseries)
data(ice.river)


To make it easy, p is how many periods a time series' partial correlation will last, we can figure it out quickly by its partial correlation coefficient chart:

pacf(prec)


It seems it will truncate in the first period, because after that the coefficient value is almost in the range of blue line. So p is 1. And q, is just how many periods a time series' correlation will last. So check the correlation coefficient chart:

acf(prec)


For the same reason, the q will be considered as 4. As for i, it means the order of the difference in data. Some data may contain time trends and seasonality, we may need to differentiate it first. Now fit a arima model and predict it:

model = arima(prec,order=c(1,0,4))
predict(model, 10)


We have the next 10 mounths' prediction:

\$pred
Time Series:
Start = c(1975, 2)
End = c(1975, 11)
Frequency = 365
[1] 3.868989 2.656401 2.863538 2.813462 2.502984 2.526123 2.524399 2.524527
[9] 2.524518 2.524518


Wish this helps, and sorry for my bad english :)

• I see that you're explaining it with an already made function. I really want to understand ARIMA step by step wihout having to use a library function – Iqbal Pratama Dec 18 '17 at 13:00

http://autobox.com/cms/index.php/afs-university/autobox-examples/modeling-with-autobox might be useful as it includes a flow diagram . In specific if you wished to include/post a complete series of your own I could detail the precise steps.