Have you considered using the auto.arima function in the 'forecast' package? It 
searches for the best ARIMA model using the AIC, AICc, or BIC criteria. It might 
save you a lot of aggravation.

 Paul Teetor, Elgin, IL  USA
http://quanttrader.info/public




________________________________
From: BSanders <adam@mycostech.com>
To: r-sig-finance@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)

-- 
View this message in context: 
http://r.789695.n4.nabble.com/I-want-to-find-the-best-arima-model-using-AIC-criterion-but-having-problems-tp3220695p3220695.html

Sent from the Rmetrics mailing list archive at Nabble.com.

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

	[[alternative HTML version deleted]]

