【问题标题】:strange result when using r ets() function for analyzing CPI data使用 rets() 函数分析 CPI 数据时出现奇怪的结果
【发布时间】:2017-05-02 06:09:03
【问题描述】:

每个人。我刚开始学习时间序列。

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

我想使用 R 中的 ets() 函数对这些数据进行一些预测。

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')

但是,我得到了下面看起来很奇怪的图表。 我得到 alpha =0、beta =0 和 gamma = 0... 这似乎意味着我没有趋势也没有季节性?

抱歉,我有很多问题..

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

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

非常感谢您提供的所有帮助..

然后我尝试使用部分数据向量[1:43]。我得到的是......

【问题讨论】:

    标签: r time-series forecasting ets


    【解决方案1】:

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

    其次,你没有指定你正在使用的forecast包的版本,甚至你正在使用forecast包的版本。因此,让我们使用当前版本的包尝试您的代码:

    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')
    

    对我来说这看起来不错,但与您发布的内容不同。

    states 矩阵的第一列包含序列的级别。在这种情况下,级别会如您所料地穿过数据的中间。

    【讨论】:

    • 非常感谢您的帮助!我使用的是最新版本的预测 8.0。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    • 2015-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-01
    相关资源
    最近更新 更多