【问题标题】:Multiple ARIMA simulate through forecast package通过预测包模拟多个 ARIMA
【发布时间】:2013-03-20 11:32:59
【问题描述】:

我为我的 ARIMA(1,1,1) 模型做了一个 10 天的点预测,我还发现可以使用预测包模拟未来的路径。

因此,我使用以下代码来模拟 10 天的未来路径。

yseries <- Arima(y,order=c(1,1,1))
simyseries <- simulate(yseries,nsim=10)

有没有办法使用simulate() 函数模拟 10000 条未来路径?

我的最终目标是将我的点预测与模拟路径一起绘制。

如果无法使用预测包,是否有其他包可以让我这样做?

【问题讨论】:

    标签: r


    【解决方案1】:

    使用replicate(),然后使用matplot() 进行多重绘图。

    y <- ts(arima.sim(model=list(order = c(1,1,1), ar=.8,ma=.7), 100)) # Simulate data
    yseries <- Arima(y,order=c(1,1,1))
    simyseries <- ts(replicate(10, simulate(yseries, nsim=10)),start=end(y)+1) # Change the first parameter of replicate() to change the number os simulated paths
    matplot(cbind(y,simyseries), type='l')
    

    【讨论】:

      【解决方案2】:

      replicate() 函数可用于将命令重复 n 次(您需要 n = 10000)。它方便地存储输出。

      yseriesSims<-replicate(10000,simulate(yseries,nsim=10))
      

      在这种情况下,结果是一个 10 X 10000 的模拟矩阵(即列包含单个模拟)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-10
        • 2020-11-18
        • 2017-11-20
        相关资源
        最近更新 更多