4

I am trying to work with ARIMA forecasting for a TS that has trends and seasonality. Hence I decompose the data into residual+trend+seasonality.

As I need to predict values out of sample, I am using exog=trend as input for the model and run prediction on residual (which is ~stationary).

This works really poorly. It seems that the trend is not taken into consideration by the model at all - when I add artificially the trend to the predicted values, i.e., plot prediction + trend, the prediction looks very close to the original series... But since I do not know the trend, I cannot do this trick. When not using additive trend, there is a seemingly constant difference between parts of the prediction and the real data.

My question is the following - can ARIMA deal with trend in Python (I know that it can in R)? How can it be imported into the model if not via exog? I tried to run ARIMA on residual+trend and it still performs badly.

Also, what is the meaning of trend = 'c' Vs trend = 'nc'? The manual says "Whether to include a constant or not. ‘c’ includes constant, ‘nc’ no constant." Constant as constant trend 0-order estimate? Constant as expected constant trend, i.e., 'nc' means varying trend? Or 'nc' as no trend included in the model? The prediction does not work well neither with this nor with that option, but if I know that there is a trend, should I always use "c"?

Help please?

Thanks.

user3861925
  • 713
  • 2
  • 10
  • 24
  • 1
    `nc` means that the long run mean is zero, no intercept and no trend. predict with exog should work to include a trend, but there was a bugfix after statsmodels 0.6.1, so I'm not sure it works with 0.6.1. – Josef Nov 30 '15 at 16:01
  • I saw the bug-fix related to: http://stackoverflow.com/questions/25044165/python-arima-exogenous-variable-out-of-sample but as I predict one value at a time, the last values is actually the first value so no problem there... Thank you, will dig deeper or write ARIMA myself which seems really redundant :-( Also, the documentation claims that the exog option should not be used for trends. Wondering why... Thanks again – user3861925 Nov 30 '15 at 16:04
  • 1
    The exog should not include a constant (a column with all identical values) because of a check to avoid conflict with internal constant. Linear trend or splines or others should be fine. (I used exog for modeling seasonal effect by splines) – Josef Nov 30 '15 at 16:40
  • @Josef I was struggling on something similar: I wanted to fit an statsmodels.tsa.ARIMA model with a linear trend, instead of just a constant one. Are you saying that the correct way to do it with an ARIMA is to give an array of time indexes to the `exog` variable ? (and also specify that we want `trend=c` ofcourse ?) – baibo Nov 18 '19 at 20:14
  • `exog` can be used for any trend or explanatory variables. We just have to be careful not to specify constant twice, in both `trend` and `exog`. AFAIR `exog` was added later than `trend` to the model. (I thought `trend` keyword can specify also linear trend, but it doesn't in ARMA and ARIMA.) – Josef Nov 18 '19 at 21:33

0 Answers0