ARIMA model producing a straight line prediction
Asked Answered
T

1

5

I did some experiments with the ARIMA model on 2 datasets

  1. Airline passengers data
  2. USD vs Indian rupee data

I am getting a normal zig-zag prediction on Airline passengers data

ARIMA order=(2,1,2)

Model Results

enter image description here

But on USD vs Indian rupee data, I am getting prediction as a straight line

ARIMA order=(2,1,2)

Model Results

enter image description here

SARIMAX order=(2,1,2), seasonal_order=(0,0,1,30)

Model Results

enter image description here

I tried different parameters but for USD vs Indian rupee data I am always getting a straight line prediction.

One more doubt, I have read that the ARIMA model does not support time series with a seasonal component (for that we have SARIMA). Then why for Airline passengers data ARIMA model is producing predictions with cycle?

Thus answered 17/7, 2019 at 16:1 Comment(3)
ARIMA produced slope straight lineBluenose
@Bluenose Ok, If ARIMA or Seasonal ARIMA couldn’t find seasonal patterns then it predict mean values (i.e. straight line). I have also tried ‘exponential smoothing’, ‘holts winter exponential smoothing’ and getting same straight line. So any other model you suggest which gives better predictions.Thus
try with facebook prophet.Bluenose
F
7

Having gone through similar issue recently, I would recommend the following:

  1. Visualize seasonal decomposition of the data to make sure that the seasonality exists in your data. Please make sure that the dataframe has frequency component in it. You can enforce frequency in pandas dataframe with the following :

    dh = df.asfreq('W') #for weekly resampled data and fillnas with appropriate method

Here is a sample code to do seasonal decomposition:

import statsmodels.api as sm

decomposition = sm.tsa.seasonal_decompose(dh['value'], model='additive', 
                            extrapolate_trend='freq') #additive or multiplicative is data specific
fig = decomposition.plot()
plt.show()

The plot will show whether seasonality exists in your data. Please feel free to go through this amazing document regarding seasonal decomposition. Decomposition

  1. If you're sure that the seasonal component of the model is 30, then you should be able to get a good result with pmdarima package. The package is extremely effective in finding optimal pdq values for your model. Here is the link to it: pmdarima example code pmdarima

If you're unsure about seasonality, please consult with a domain expert about the seasonal effects of your data or try experimenting with different seasonal components in your model and estimate the error.

Please make sure that the stationarity of data is checked by Dickey-Fuller test before training the model. pmdarima supports finding d component with the following:

from pmdarima.arima import ndiffs
kpss_diff = ndiffs(dh['value'].values, alpha=0.05, test='kpss', max_d=12)
adf_diff = ndiffs(dh['value'].values, alpha=0.05, test='adf', max_d=12)
n_diffs = max(adf_diff , kpss_diff )

You may also find d with the help of the document I provided here. If the answer isn't helpful, please provide the data source for exchange rate. I will try to explain the process flow with a sample code.

Flick answered 23/7, 2019 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.