Python 和 Scipy 中的季节调整
我希望使用 Python 季节性调整每月数据。从这些系列中可以看出:www.emconfidential.com,季节性很高数据的组成部分。我想对此进行调整,以便我可以更好地判断系列趋势是上升还是下降。有人知道如何使用 scipy 或其他 Python 库轻松做到这一点吗?
I am looking to seasonally adjust monthly data, using Python. As you can see from these series: www.emconfidential.com, there is a high seasonal component to the data. I would like to adjust for this so that I can better guage if the series trend is rising or falling. Anybody know how to do this easily using scipy or other Python library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
统计模型可以做到这一点。它们具有基本的季节性分解以及 Census X13 调整的包装。您还可以使用 rpy2 访问 R 的一些优秀的 SA 库。这是 statsmodels 季节性分解:
http://statsmodels.sourceforge.net/0.6 .0/release/version0.6.html
Statsmodels can do this. They have a basic seasonal decomposition and also a wrapper to Census X13 adjustment. You could also use rpy2 to access some of R's excellent SA libraries. Here is statsmodels seasonal decomp:
http://statsmodels.sourceforge.net/0.6.0/release/version0.6.html
现在有一个软件包似乎正是您正在寻找的!查看
seasonal
包,这里是链接 。我个人觉得非常有用,想知道其他人的想法。There is now a package that seems to be exactly what you are looking for! Check out the
seasonal
package, here is the link. I personally found it to be very useful, wondering what others think.没有神奇的 Python 库可以为你进行季节性调整。执行此类操作的应用程序往往相当大。
您需要自己计算出数学,然后使用 scipy 计算其余部分为你。
There's no magical python library that will do seasonal adjustments for you. Applications that do this kind of thing tend to be rather large.
You'll need to work out the maths yourself and then use scipy to calculate the rest for you.
我建议使用 Facebook 数据科学团队开发的 Prophet 。它具有 Python+R API,用于时间序列预测,尽管您可以仅使用它将序列分解为其组件(趋势与季节性)。您可以轻松调整和可视化分解:
I would suggest Prophet developed by the data science team at Facebook. It has Python+R API and is used for time-series prediction although you can use it just for decomposing your series into its components (trend vs seasonality). You can easily adjust and visualize the decomposition:
不确定这方面的编程,但我会认真考虑移动平均线来解决这个问题。
Not sure on the programming aspect of this but I would seriously consider moving averages to solve this.