代码之家  ›  专栏  ›  技术社区  ›  user3787315

使用“rollmedian”函数作为“arima”函数的输入

  •  1
  • user3787315  · 技术社区  · 10 年前

    我的时间序列数据包括日期时间和温度列,如下所示:

    rn25_29_o:

      ambtemp                  dt
    1   -1.96 2007-09-28 23:55:00
    2   -2.02 2007-09-28 23:57:00
    3   -1.92 2007-09-28 23:59:00
    4   -1.64 2007-09-29 00:01:00
    5   -1.76 2007-09-29 00:03:00
    6   -1.83 2007-09-29 00:05:00
    

    我使用中值平滑函数来增强由于测量不精确而导致的小波动。

    unique_timeStamp <- make.time.unique(rn25_29_o$dt) 
    temp.zoo<-zoo(rn25_29_o$ambtemp,unique_timeStamp)
    m.av<-rollmedian(temp.zoo, n,fill = list(NA, NULL, NA))
    

    随后,中值平滑的输出用于构建时间模型并通过使用以下代码实现预测:

    te = (x.fit = arima(m.av, order = c(1, 0, 0)))
    # fit the model and print the results
    x.fore = predict(te, n.ahead=50)
    

    最后,我遇到了以下错误:

    seq.default(head(tt,1),tail(tt、1),delta)中出错:'by' 争论太小了

    仅供参考:通过使用原始时间序列数据,建模和预测功能可以正常工作。

    请引导我克服这个错误。

    1 回复  |  直到 5 年前
        1
  •  1
  •   Wil    5 年前

    出现问题的原因是动物园软件包的财产。

    因此,可将代码修改为:

    Median_ambtemp <- rollmedian(ambtemp,n,fill = list(NA, NULL, NA))                                      te = (x.fit = arima(Median_ambtemp, order = c(1, 0, 0)))   
    # fit the model and print the results
    x.fore = predict(te, n.ahead=5)