时间序列最简单的季节性测试是什么?
更具体地说,我想测试 inspecific time series the seasonal component
是否有意义。
Python/R 中推荐的包是什么?
时间序列最简单的季节性测试是什么?
更具体地说,我想测试 inspecific time series the seasonal component
是否有意义。
Python/R 中推荐的包是什么?
在测试季节性之前,您应该反映您拥有的季节性类型。请注意,有许多不同类型的季节性:
检测季节性的最常用方法之一是将时间序列分解为几个分量。
在 R 中,您可以使用decompose()
预安装的 stats 包中的stl()
命令或预测包中的命令来执行此操作。
以下代码取自A little book of R for time series
births <- scan("http://robjhyndman.com/tsdldata/data/nybirths.dat")
birthstimeseries <- ts(births, frequency = 12, start = c(1946,1))
birthstimeseriescomponents <- decompose(birthstimeseries)
plot(birthstimeseriescomponents)
您可以检查单个组件
birthstimeseriescomponents$seasonal
birthstimeseriescomponents$random
birthstimeseriescomponents$trend
另一种方法是包括季节性虚拟变量,并在计算回归时检查它们是否具有显着的 p 值。如果单个月份具有显着系数,则您的每月时间序列是季节性的。
检测季节性的另一种方法是绘制数据本身或绘制 ACF(自相关函数)。在我们的例子中,您可以很容易地注意到存在季节性。
最后但并非最不重要的是,为了检测季节性,有一些“正式的”假设检验,例如学生 T 检验和 Wilcoxon 符号秩检验。