[R] Search for best ARIMA model

Juan Antonio Breña Moral bren at juanantonio.info
Mon Sep 11 11:44:38 CEST 2006


Hi, to create best ARIMA model, I use the package forecast.

You can search it in the following URL:

http://www-personal.buseco.monash.edu.au/~hyndman/Rlibrary/forecast/

You should use the method "best.arima"

further information, here:
http://www-personal.buseco.monash.edu.au/~hyndman/Rlibrary/forecast/forecast/best.arima.html

Best Regards.


Schweitzer, Markus wrote:
> 
> Hello,
> 
> I have a several time series, which I would like to check for their best
> fitted Arima model (I am checking for the lowest aic value).
> Which lets me raise two questions:
> 
> 1) is there are more efficient way, than using 6 for-loops?
> 2) sometimes the system cannot calculate  with given parameters - is
> there a more efficient solution than I found?
> 
> I hope, you can help me to make this calculation quicker since I have to
> run this function 450 times...
> Thank you very much in advance,
> 
> Markus
> 
> 
> arima.estim <- function(TS) {
> 	best.model <- arima(TS, order = c(1, 0, 0), seasonal =
> list(order = c(0, 0, 0), period = frequency(TS)) )
> 
> # Start value
> # I continue with brute force- p, q, r, s are nested from 0 to 3 and i
> and j are nested from 0 to 2. p and  q are not both allowed to be 0.
> 
> for (p in 0:3){
>   for( q in 0:3){
>     if(p==0 && q==0) {}
>       else {
>         for(r in 0:3) {
>           for(s in 0:3) {
>             for (j in 0:2) {
>               for(i in 0:2) {
>       
> # test, if series works
>     if(inherits(try(arima(TS, order = c(p, i, q), seasonal = list(order
> = c(r,  j, s), period = frequency(TS)) ), TRUE), 'try-error')){
>         
> 	print(c(p,i,q))} #shows, which parameters didn't work -> will be
> removed by
>        
> 	 else    {
> 	         tmp <- arima(TS, order = c(p, i, q), seasonal =
> list(order = c(r,  j, s), period = frequency(TS)))     # calculate again
> :(
> 
>           if(best.model$aic > tmp$aic)
>           {
>                   best.model <- tmp
>           }
>               }
>                  }
>                  }    
>                  }
>                  } } } } 
>                  
>                  best.model}
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help en stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/Search-for-best-ARIMA-model-tf2156910.html#a6243692
Sent from the R help forum at Nabble.com.



More information about the R-help mailing list