简体   繁体   English

时间序列预测、平稳性分析

[英]Time series forecasting, analysing stationarity

I have a yearly data of carbon emission from 1990 to 2017(28 datapoints) and I want to perform Time series forecasting on it.我有一个从 1990 年到 2017 年的年度碳排放数据(28 个数据点),我想对其进行时间序列预测。 The rolling mean of the data with a window of 2 keeps increasing with time that indicates my data is not stationary but dicky-fuller test gives a p-value of 0.04 which is less then 0.05, hence this indicates that the data is stationary. window 为 2 的数据的滚动平均值随着时间的推移不断增加,这表明我的数据不是平稳的,但 dicky-fuller 检验给出的 p 值为 0.04,小于 0.05,因此这表明数据是平稳的。 What can be done in this situation?在这种情况下可以做些什么?

def rolling_stats(time_data):
     rolling_mean=time_data.rolling(2).mean()
     rolling_std=time_data.rolling(2).std()
     raw_data=plt.plot(time_data,color="blue",label="Original Data")
     mean=plt.plot(rolling_mean,color="green",label="mean")
     std=plt.plot(rolling_std,color="red",label="std")
     plt.legend(loc="best")
     plt.title("Mean and standard deviation")
     plt.xlabel("Years")
     plt.ylabel("Carbon emitted in megatonnes")
rolling_stats(CarbonEmitted)

在此处输入图像描述

Without seeing the code/data it's hard to see what you did wrong, for example, you could have performed adfuller on the standard deviation or something.如果没有看到代码/数据,很难看出你做错了什么,例如,你可能在标准偏差或其他东西上表现得更糟。 Your data should be of the format您的数据应采用以下格式

Date日期 Emission排放
1992-01-01 1992-01-01 21 21
1993-01-01 1993-01-01 20.5 20.5

Date is usually set as the index and your dates should be of the type datetime日期通常设置为索引,您的日期应该是日期时间类型

The ADF test is used to determine if differencing the data will create staionairty, thus inferring that the current data is not. ADF 测试用于确定对数据进行差分是否会产生 staionairty,从而推断当前数据不是。 I don't have your data so I cannot tell if it does, but what you want to test is whether differencing the data results in random noise centered at 0. If you do not get stationary data when performing ADF then that may be why ADF is failing on your original data.我没有你的数据,所以我不知道它是否有,但你想要测试的是差异数据是否会导致以 0 为中心的随机噪声。如果在执行 ADF 时没有得到固定数据,那么这可能就是 ADF 的原因您的原始数据失败。

There are other tests you can look into, sometimes differencing isn't required to make data stationary and a log transform is more appropriate, experiment with your data and see.您可以查看其他测试,有时不需要差异来使数据静止,并且对数转换更合适,对您的数据进行试验并查看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM