大多数时候一个人跑步arima.sim()
函数来模拟特定的顺序arima mosel
但是当人们通过检查此类模拟时间序列数据时auto.arima()
函数,它通常不会与 ARIMA 一个愿望和在arima.sim()
.
我想知道一个人可能需要跑多少次arima.sim()
在获得所需模型的真实阶数之前,对其参数(样本大小、标准差和模型系数)的不同组合进行函数处理,我想要这个R
脚本到count
它将运行多少次arima.sim()
在得到摘录之前ARIMA-order
中指定的arima.sim()
功能。
**Here is my trial**
library(forecast)
N <- c(10, 20, 30)
SD <- c(1, 2, 3, 4, 5) ^ 2
phi <- c(0.2, 0.4, 0.6)
## generate all combos
all_combos <- expand.grid(N = N, SD = SD, phi = phi)
## create function
set.seed(123)
res2 <- by(all_combos, all_combos["N"], function(DF){
res <- mapply(function(N, SD, phi){
cnt <- 0
repeat {
x <- arima.sim(n=N, model = list(ar=phi, order = c(1, 0, 0)), sd = SD)
if(all(arimaorder(auto.arima(x), ic = "aicc"))) != c(1, 0, 0) cnt <- cnt + 1){
}
{else(all(arimaorder(auto.arima(x), ic = "aicc"))) == c(1, 0, 0) cnt <- cnt + 1)}
break
}
cnt
}, DF[["N"]], DF[["SD"]], DF[["phi"]])
names(res) <- paste("SD", DF[["SD"]], "phi", DF[["phi"]], sep = "-")
res
})
res2
我有兴趣知道有多少次试验arima.sim()
在获得第一个 ARIMA(1, 0, 0) 之前会进行哪些操作。