在趋势线上投影时间序列预测并包括季节性(Python) [英] Projecting time series predictions on trend line and including seasonality (Python)

查看:40
本文介绍了在趋势线上投影时间序列预测并包括季节性(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里,我对使用 statsmodels (Python) 的时间序列感到疯狂.我是 TS 领域的新手,虽然我对各种回归模型有更好的理解.这是我的问题:

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:

我有一个固定化的时间序列(通过season_decompose 或差分).我还使用 ACF 和 PACF 图计算了 ARIMA 模型的参数 p、d 和 q.我将模型拟合在平稳 TS 或残差上(我从 season_decompose 得到).很高兴,我也得到了一个预测.

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.

但现在我的问题是我的预测也是平稳的.我需要一个趋势和季节性周期.假设我有时间 t1-t100 的数据,我需要从 t101-t110 进行预测.t101-t110 的预测是平稳的,我不知道如何将其投影到趋势线上并包括周期.

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.

有人能解释一下我如何包含预测和来自seasonal_decompose 函数的组件以获得所需的结果.

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

推荐答案

在代码方面,您可以使用以下代码来查看seasonal_decompose 向您展示的内容

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.

代码来源

这篇关于在趋势线上投影时间序列预测并包括季节性(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆