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]]

______________________________________________
[email protected] 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.

Reply via email to