Home > database >  How to extract the arima order (non seasonal: p,d,q and seasonal: P,D,Q) from the auto.arima model o
How to extract the arima order (non seasonal: p,d,q and seasonal: P,D,Q) from the auto.arima model o

Time:10-22

Trying to extract the arima order, received by using the auto.arima function, gives me a big headache.

Here is an example, that is producing a seasonal arima model:

my_data <- c(232,294,320,314,336,189,331,185,161,140,49,7,0,3,4,9,38,169,275,316,366,422,328,283,213,238,220,193,250,308,224,190,188,99,41,17,19,9,1,3,10,108,149,189,168,170,155,101,119,89,142,169,192,242,152,141,105,76,39,20,17,13,5,3,8,54,102,102,155,159,164,200,183,144,204,190,219,158,128,142,130,86,58,13,12,0,6,4,20,302,297,312,345,293,233,275,233,199,279,250,208,161,200,181,133,140,17,14,2,0,2,4,36,183,379,371,356,425,320,282,172,214,226,250,196,239,183,194,135,75,28,11,2,3,5,4,29,212,316,343,375,431,225,248,209,258,262,230,218,162,193,178,126,131,37,7,5,3,0,1,20,149,258,408,316,307,352,247,285,236,254,321,233,175,264,114,104,82,37,49,4,16,2,14,22,169,259,355,379,346,261,256,220,238,227,201,242,185,121,160,114,91,33,9,4,2,0,2,22,62,114,156,190,186,140,155,141,135,140,137,179,128,156,124,98,66,63,32,27,0,21,5,4,39,73,162,175,207,183,121,174,107,160,177,258,170,152,165,117,59,35,69,7,0,3,3,28,98,165,194,200,190,162,160,170,200,189,187,141,224,152,115,111,47,20,15,2,0,0,29,10,59,170,212,164,201,193,182,277,283,376,310,194,247,177,164,140,192,95,49,10,10,2,5,38,52,156,331,480,378,231,172,132,199,245,267,192,223,182,168,152,81,20,14,13,6,14,16,6,21,51,113,94,103,113,93,205,98,118,97,138,112,98,99,79,74,71,38,31,30,31,38,41,48,131,159,212,134,150,145,149,105,142,149,122,137,193,105,68,75,35,33,41,38,33,29,44,54,85,109,118,117,113,107,112,92,112,98,111,81,120,113,66,55,10,20,26,25,3,10,15,30,60,91,97,67,100,99,75,92,98,126,116,103,110,87,124,66,55,30,31,28,28,31,29,49,109,144,152,116,106,88,164,127,121,161,186,104,81,79,103,69,47,35,35,30,28,34,42,56,114,110,149,153,112,151,138,151,141,139,206,225,166,173,185,384,221,100,61,51,35,44,38,83,87,182,205,243,191,144,106,112,167,234,147,136,152,107,156,53)
 myts <- ts(my_data, start=c(2010, 1), end=c(2030, 10), frequency=24)
 
test_model <-  auto.arima(myts, seasonal = T)

# output:
Series: myts 
ARIMA(1,0,1)(2,1,0)[24] with drift 

Coefficients:
         ar1      ma1     sar1     sar2    drift
      0.8117  -0.2143  -0.6528  -0.2886  -0.1288
s.e.  0.0383   0.0650   0.0486   0.0484   0.1973

sigma^2 = 2172:  log likelihood = -2454.94
AIC=4921.88   AICc=4922.06   BIC=4946.74

I was trying test_model$arma, which gives me the wrong order parameters. Also a solution considering test_model$model$phi, test_model$model$theta and test_model$model$Delta, gives me vectors instead of a single integer.

Is there even a possibility, to extract these results? Please help...

CodePudding user response:

I think you're after forecast::arimaorder

library(forecast)
test_model <-  auto.arima(myts, seasonal = T)

arimaorder(test_model)
#        p         d         q         P         D         Q Frequency 
#        1         0         1         2         1         0        24 

arimaorder returns a named numeric vector, giving the values for p, d, q, P, D, Q, m (if the model is a seasonal ARIMA model).

  • Related