问题
I want to simulate 10 ARIMA
time-series data that will have the following order (1,0,1), (1,1,1) and (2,2,2)
. such that if I test each series with auto.arima
function of forecast
package it will give me what I have specified.
I have tried these
set.seed(123)
n <- 10
# white noise:
wn <- ts(rnorm(n))
# initialise the first two values:
arma11 <- arma22 <- wn[1:2]
# loop through and create the 3:1000th values:
for(i in 3:n){
arma11[i] <- arma11[i - 1] * 0.8 + wn[i - 1] * 0.3 + wn[i]
arma22[i] <- arma22[i - 1] * 0.862537 + arma22[i - 2] * (-0.3) + 0.8 * wn[i-1] -
0.3 * wn[i-2] + wn[i]
}
# turn them into time series, and for the last two, "integrate" them via cumulative sum
arma11 <- ts(arma11)
arima111 <- ts(cumsum(arma11))
arima222 <- ts(cumsum(cumsum(arma22)))
Test for ARIMA order
auto.arima(arma11, ic=c("bic"), approximation = F, allowdrift =F)
auto.arima(arima111, ic=c("bic"), approximation = F, allowdrift =F)
auto.arima(arima222, ic=c("bic"), approximation = F, allowdrift =F)
None of arma11 or arima111 or arima222 gives me the order I specified, can someone help me out?
回答1:
On the programming side, you can use arima.sim()
.
sim <- arima.sim(n=100, list(order = c(1, 0, 1), ar=0.7, ma=-0.3), sd=sqrt(0.5))
auto.arima(sim, allowmean=FALSE, allowdrift=FALSE, trace=TRUE)
You should realize that estimating an ARIMA model is not a clean process. The very first thing that stands out to me is that n=10
might be too small to estimate reliably. With trace=TRUE
, you can see that how close things can be between the candidate models. auto.arima()
goes through quite many steps unless you specify the parameters precisely.
来源:https://stackoverflow.com/questions/58472464/how-do-i-simulate-10-arima-time-series-data-of-specified-orders-using-r