2017-05-02 32 views
0

everyone。我刚开始学习时间系列。使用rts()函数分析CPI数据的奇怪结果

我有以下来自中国的月度CPI数据(2010.01 - 2015.12)。

我想使用ETS从R.

vector1 <- c(100.6, 101.2, 99.3, 100.2, 99.9, 99.4, 100.4, 100.6, 100.6, 100.7, 101.1, 100.5, 101.0, 101.2, 99.8, 100.1, 100.1, 100.3, 100.5, 100.3, 100.5, 100.1, 99.8, 100.3, 101.5, 99.9, 100.2, 99.9, 99.7, 99.4, 100.1, 100.6, 100.3, 99.9, 100.1, 100.8, 101.0, 101.1, 99.1, 100.2, 99.4, 100.0, 100.1, 100.5, 100.8, 100.1, 99.9, 100.3, 101.0, 100.5, 99.5, 99.7, 100.1, 99.9, 100.1, 100.2, 100.5, 100.0, 99.8, 100.3, 100.3, 101.2, 99.5, 99.8, 99.8, 100.0, 100.3, 100.5, 100.1, 99.7, 100.0, 100.5) 

做一些预测与此数据()函数我试图按照从下面的链接的过程: https://stats.stackexchange.com/questions/146098/ets-function-how-to-avoid-forecast-not-in-line-with-historical-data

的代码是如如下:

train_ts<- ts(vector1, frequency=12) 
fit2<-ets(train_ts, model="ZZZ", damped=TRUE, alpha=NULL, beta=NULL, gamma=NULL, 
     phi=NULL, additive.only=FALSE, lambda=TRUE, 
     lower=c(0.000,0.000,0.000,0.8),upper=c(0.9999,0.9999,0.9999,0.98), 
     opt.crit=c("lik","amse","mse","sigma","mae"), nmse=3, 
     bounds=c("both","usual","admissible"), ic=c("aicc","aic","bic"), 
     restrict=TRUE) 
ets <- forecast(fit2,h=5,method ='ets') 

plot(forecast(fit2)) 
lines(fit2$states[,1],col='red') 

但是,我得到了下图,看起来很奇怪。 我得到α= 0,β= 0和γ= 0 ...这似乎意味着我没有趋势,没有季节性?

enter image description here

对不起,我有很多问题..

  1. 是否预测是否正确?我认为这里有些问题,但我无法弄清楚问题所在。

  2. “fit2 $ states [,1]”代表什么?红线代表什么?

非常感谢所有帮助那种..

然后我试图使用数据矢量[1:43]的一部分。我得到的是... enter image description here

回答

1

首先,平滑参数接近零并不意味着你没有水平,趋势或季节性。他们的意思是水平,趋势或季节性不会随时间变化。请参阅https://www.otexts.org/fpp/7

其次,你不认为你正在使用,甚至认为你正在使用的预测包指定预测包的版本。因此,让我们使用软件包的最新版本试试你的代码:

library(forecast) 
vector1 <- c(100.6, 101.2, 99.3, 100.2, 99.9, 99.4, 100.4, 100.6, 
    100.6, 100.7, 101.1, 100.5, 101.0, 101.2, 99.8, 100.1, 100.1, 100.3, 
    100.5, 100.3, 100.5, 100.1, 99.8, 100.3, 101.5, 99.9, 100.2, 99.9, 
    99.7, 99.4, 100.1, 100.6, 100.3, 99.9, 100.1, 100.8, 101.0, 101.1, 
    99.1, 100.2, 99.4, 100.0, 100.1, 100.5, 100.8, 100.1, 99.9, 100.3, 
    101.0, 100.5, 99.5, 99.7, 100.1, 99.9, 100.1, 100.2, 100.5, 100.0, 
    99.8, 100.3, 100.3, 101.2, 99.5, 99.8, 99.8, 100.0, 100.3, 100.5, 
    100.1, 99.7, 100.0, 100.5) 
train_ts <- ts(vector1, frequency=12) 
fit2 <- ets(train_ts, damped=TRUE) 
ets <- forecast(fit2, h=5) 
plot(forecast(fit2)) 
lines(fit2$states[,1],col='red') 

enter image description here

这看起来OK我,不一样的你发布的内容。

states矩阵的第一列包含系列的级别。在这种情况下,级别会像您期望的那样遍历数据的中间。

+0

非常感谢您的帮助!我正在使用最新版本的预测8.0。 –