2017-05-02 20 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。 –