Data Forecasting with ARIMA Model Part -3


Continuation to Part-2 , here I am discussing about ARIMA model in Data Forecasting with same example of Air Passengers

What is ARIMA ?
ARIMA stands for Auto Regressive Integrated Moving Average .
It is based on assumptions that  over a period of times  that current values are correlated with immediate previous  value  or n th previous value.
The parameters of the ARIMA model are defined as follows:
p=The number of lag observations included in the model, also called the lag order.
d=The number of times that the raw observations are differences.
q=The size of moving average window, also called the order of moving average.

  In order to find the p,d,q values we need to plot the ACF and PACF  graphs , ACF stands for auto correlation function which refers Moving average and gives values of p and PACF stands for Partial Auto Correlation Function which refers Auto Regressive and gives q values.
Checking Errors in Model :
There are different error checking methods like
  •  ME : Mean Error
  • RMSE : Root Mean Squared Error
  • MAE:  Mean Absolute Error 
  • MPE: Mean Percentage Error
  • MAPE: Mean Absolute Percentage Error.
  • MASE : Mean Absolute Scaled Error 
  • ACFI: Auto Correlation of Error at lag1 -Error 
 Let's go for practical example of Air passengers data set which is used in previous Prophet Model
Step 1:
Install and import package forecasting
>>library(forecast)
Reading data in to r studio  is same for all models ,
Step2:
Creation of Time series to the data for  every forecasting models require Time series along with the data
# Creation of Time series to data
>> Time_series_Data<-ts(Dataframe_source$y, start = c(1949,01,01), end=c(1960,12,01), frequency = 12)
Step3:
#checking Difference Lag of data 
>> Diff_value<-diff(Time_series_Data,differences = 1)
>> plot(Diff_value)
It is check the number of times that the raw observations are differences.
Step4:
#ACF(Auto Correlation Function)         -
>> acf(Diff_value)

ACF plots display correlation between a series and its lags, which refers q value.
Step 5:
#PACF(Partial Auto Correlation Function)
>> pacf(Diff_value)

It to  refers q value
Step 6:
#Building ARIMA Model 
>> Arima_Model<- arima(Time_series_Data, order = c(2,1,1))
>> Arima_Model

In order we are using the p,d,q values
step 7:
#Forecasting ARIMA Model
>> Arima_model_forecasting<-forecast(Arima_Model,h=10)
>> Arima_model_forecasting

here we passing the Arima_Model and frequency (h) as the parameters , so we will get 10 months future data.
step 8:
#ploting Arima_model_forecasting
>>  plot(Arima_model_forecasting)
 Plot forecasting  data
we can also build Automatic  ARIMA  which take ACF and PACF values directly by ARIMA which called as Auto ARIMA
Let's  see how to built ARIMA model with R



































Comments

Popular posts from this blog

What is linear regression ?

Prophet function in r Part - 2

Work flow to build a Machine Learning Algorithm