________________________________
From: BSanders<adam at mycostech.com>
To: r-sig-finance at stat.math.ethz.ch
Sent: Sun, January 16, 2011 10:42:14 PM
Subject: [R-SIG-Finance] I want to find the best arima model using AIC
criterion, but having problems
I'm running a loop for trying to find the best ARIMA seasonal model. I'm
experimenting with different orders of AR, MA and differencing.., but when I
run my loops, I'm getting an error such as
"Error in optim(init[mask], armafn, method = optim.method, hessian = TRUE,
:
non-finite finite-difference value [3]
"
and R exits the loop, however, it isn't finished. Is there a way to make R
continuing what it should?
My code looks like this below :
count = 0
for(i in 0:7){
for(j in 0:2) {
for(k in 0:1) {
for(l in 0:1) {
for(m in 0:2) {
for(n in 0:1) {
for(o in 1:2) {
model = arima(y, order=c(i,j,k), seasonal=list(order=c(l,m,n), period=7*o))
if (count == 0){
aicmin = model$aic
bestmodel = model
}
if ((count != 0)&& (model$aic< aicmin)){
aicmin = model$aic
bestmodel = model
diff1 = j
diff2 = m
seas = o*7
}
count = count+1
}
}
}
}
}
}
}
print(bestmodel)
print(count)
print(diff1)
print(diff2)
print(seas)