title: how to extract integration order (d) from auto.arima
body: <p>basically we can extract optimum AR order from auto.arima by</p>
  
  <pre><code>&gt; auto.arima(ret.fin.chn,trace=TRUE,allowdrift=TRUE)
  
    ARIMA(2,0,2) with non-zero mean : -14242.19
    ARIMA(0,0,0) with non-zero mean : -14239.24
    ARIMA(1,0,0) with non-zero mean : -14241.3
    ARIMA(0,0,1) with non-zero mean : -14238.16
    ARIMA(1,0,2) with non-zero mean : -14237.65
    ARIMA(3,0,2) with non-zero mean : -14242.72
    ARIMA(3,0,1) with non-zero mean : -14239.52
    ARIMA(3,0,3) with non-zero mean : -14242.5
    ARIMA(2,0,1) with non-zero mean : -14237.15
    ARIMA(4,0,3) with non-zero mean : -14238.06
    ARIMA(3,0,2) with zero mean     : -14244.39
    ARIMA(2,0,2) with zero mean     : -14243.98
    ARIMA(4,0,2) with zero mean     : -14241.45
    ARIMA(3,0,1) with zero mean     : -14241.23
    ARIMA(3,0,3) with zero mean     : -14244.04
    ARIMA(2,0,1) with zero mean     : -14238.78
    ARIMA(4,0,3) with zero mean     : -14239.73
  
  
   Best model: ARIMA(3,0,2) with zero mean
  
  
   Series: ret.fin.chn 
   ARIMA(3,0,2) with zero mean     
  
   Coefficients:
            ar1      ar2     ar3      ma1     ma2
         0.5497  -0.4887  0.0461  -0.5691  0.4923
   s.e.  0.3525   0.1764  0.0232   0.3534  0.1878
  
   sigma^2 estimated as 0.0003277:  log likelihood=7127.67
   AIC=-14243.35   AICc=-14243.32   BIC=-14207.83
   Warning messages:
   1: In if (is.constant(x)) { :
     the condition has length &gt; 1 and only the first element will be used
   2: In if (is.constant(x)) return(d) :
     the condition has length &gt; 1 and only the first element will be used
   3: In if (is.constant(dx)) { :
     the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>now store the result to object a</p>
  
  <pre><code>&gt; a&lt;-auto.arima(ts(ret.fin.chn),trace=TRUE,allowdrift=TRUE)
  </code></pre>
  
  <p>then</p>
  
  <pre><code>&gt; a$arma[1]
  </code></pre>
  
  <p>while for optimum MA order by</p>
  
  <pre><code>&gt; a$arma[2]
  </code></pre>
  
  <p>now look at this part <strong><em>Best model: ARIMA(3,0,2) with zero mean</em></strong>
  this is the ARIMA(p,d,q) order
  i've known how to extract the AR(p) and MA(q) order but how to extract the Integration(d) order and note in mind that i've tried the <code>ndiffs</code> and sometimes it gives different result than the best model perhaps it's somewhere in <code>$arma[?]</code>???</p>