Projecting time series predictions on trend line and including seasonality (Python)
Asked Answered
A

1

1

For the past few days I'm going crazy with Times series using statsmodels (Python). I am a novice in the TS area, although i do have a better understanding of various regression models. Here is my issue:

I have a time-series that I stationarized (either by seasonal_decompose, or by differencing). I also figured out the parameters p,d, and q for the ARIMA model, using ACF and PACF plots.I fit the model on the stationarized TS or the residual (i got from seasonal_decompose). Gladly, i also got a prediction.

But now my problem is that my prediction is also stationary. I need a trend and seasonal cycles on it. Lets say I have data for time t1-t100 and i need to predict from t101-t110. The prediction for t101-t110 is stationary, and I have no idea how to project it on the trendline and include the cycles.

Can someone explain how I can include the prediction and the components from the seasonal_decompose function to get the desired results.

Athos answered 27/7, 2016 at 15:58 Comment(0)
R
0

In terms of code, you can use the following to see what seasonal_decompose is showing you

from statsmodels.tsa.seasonal import seasonal_decompose
series = ...
result = seasonal_decompose(series, model='additive')
print(result.trend)
print(result.seasonal)
print(result.resid)
print(result.observed)

then you can work with the residual and model it as you did.

To reverse engineer your way back to real data pattern by adding trend + seasonality you need to model the trend (using moving average etc.) and seasonality (using auto-regression etc). decomposing is a tool for guide the analysis, not solve the problem.

source for code

Rosco answered 28/4, 2020 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.