[R] Search for best ARIMA model

From: Schweitzer, Markus <Markus.Schweitzer_at_hilti.com>
Date: Thu 24 Aug 2006 - 16:27:51 EST


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@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. Received on Thu Aug 24 16:32:19 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 13 Sep 2006 - 02:00:38 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.