If you look at ?auto.arima
, you will know that it returns the same object as stats::arima
. If you further look at ?arima
, you see that the information you want can be found from $model
of the returned value. The detail of $model
can be read from ?KalmanLike
:
phi, theta: numeric vectors of length >= 0 giving AR and MA parameters.
Delta: vector of differencing coefficients, so an ARMA model is
fitted to ‘y[t] - Delta[1]*y[t-1] - ...’.
So, you should do:
p <- length(fit$model$phi)
q <- length(fit$model$theta)
d <- fit$model$Delta
Example from ?auto.arima
:
library(forecast)
fit <- auto.arima(WWWusage)
length(fit$model$phi) ## 1
length(fit$model$theta) ## 1
fit$model$Delta ## 1
fit$coef
# ar1 ma1
# 0.6503760 0.5255959
Alternatively (actually better), you can refer to the $arma
value:
arma: A compact form of the specification, as a vector giving the
number of AR, MA, seasonal AR and seasonal MA coefficients,
plus the period and the number of non-seasonal and seasonal
differences.
But you need to match them correctly and carefully. For the example above, there is:
fit$arma
# [1] 1 1 0 0 1 1 0
Using the notation ARIMA(p,d,q)(P,D,Q)[m]
, we can add name attribute for clear presentation:
setNames(fit$arma, c("p", "q", "P", "Q", "m", "d", "D"))
# p q P Q m d D
# 1 1 0 0 1 1 0