从拟合模型模拟时间序列

Simulate time series from a fitted model

如何从不同长度的拟合模型模拟时间序列?
这是我使用的 R 代码。

library(forecast)
x <- rnorm(14)
arima_mtd <- auto.arima(x)
simulate(arima_mtd, future=FALSE, obs=20)

输出是

Time Series:
Start = 1 
End = 14 
Frequency = 1 
 [1]  2.5615390  2.5141284  4.2861222  3.6109683  3.3430394  1.2106125  0.6632493  0.3742014 -0.9513123 -0.3542338  0.5117973 -0.3833429 -0.2657833 -0.8910624

我不想生成 14 个观测值,而是想从拟合模型生成 20 个观测值。

恕我直言,当您只有 14 个观察值并且 future = FALSE 时,您只能生成 14 个模拟观察值。如果你需要 20 个,你必须通过设置 future = TRUE:

来生成 6 个以上的观察值
a = simulate(arima_mtd, future = FALSE, nsim = 14)
b = simulate(arima_mtd, future = TRUE, nsim = 6)

或者您将不得不增加初始 x 中的观察次数。