Often times I make use of arima.sim()
function to simulate ARIMA
model and later discover through auto.arima()
function that the ARIMA
model simulated is not the same with what I specified in arima.sim()
function.
I went further to investigate to know how does the arima.sim()
fair in simulating ARIMA
model by simulating same ARIMA
model with the same arima.sim()
detail good number of times and then check each out with auto.arima()
here.
result <- matrix(NA_integer_, nrow = 10, ncol = 3)
colnames(result) <- c("p","d","q")
num<-60
set.seed(1234)
for(i in 1:10){
result[i, ] <- arima.sim(n = num, model=list(ar=0.8, order = c(1, 0, 0))) %>%
auto.arima() %>%
arimaorder()
}
result
#p d q
#1 0 1
#1 0 0
#1 0 0
#1 0 0
#2 0 1
#1 0 0
#1 0 0
#1 0 0
#1 0 0
#4 0 3
How do I put up an R
code that will count how many
times ARIMA(1, 0, 0)
comes up when I run
num<-60
for(i in 1:10){
ar1 <- arima.sim(n = num, model=list(ar=0.8, order = c(1, 0, 0)))
auto.arima(ar1)
}
ten(10) times in a loop