Plotting the characteristic roots for ARIMA models

[This article was first published on Hyndsight » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

When modelling data with ARIMA models, it is sometimes useful to plot the inverse characteristic roots. The following functions will compute and plot the inverse roots for any fitted ARIMA model (including seasonal models).

# Compute AR roots
arroots <- function(object)
  if(class(object) != "Arima" & class(object) != "ar")
    stop("object must be of class Arima or ar")
  if(class(object) == "Arima")
    parvec <- object$model$phi
    parvec <- object$ar
  if(length(parvec) > 0)
    last.nonzero <- max(which(abs(parvec) > 1e-08))
    if (last.nonzero > 0)
      type="AR"), class='armaroots'))
# Compute MA roots
maroots <- function(object)
  if(class(object) != "Arima")
    stop("object must be of class Arima")
  parvec <- object$model$theta
  if(length(parvec) > 0)
    last.nonzero <- max(which(abs(parvec) > 1e-08))
    if (last.nonzero > 0)
      type="MA"), class='armaroots'))
plot.armaroots <- function(x, xlab="Real",ylab="Imaginary",
    main=paste("Inverse roots of",x$type,"characteristic polynomial"),
  oldpar <- par(pty='s')
       type="n",bty="n",xaxt="n",yaxt="n", main=main, ...)
  circx <- seq(-1,1,l=501)
  circy <- sqrt(1-circx^2)
  if(length(x$roots) > 0) {
    inside <- abs(x$roots) > 1
    if(sum(!inside) > 0)

The arroots function will return the autoregressive roots from the AR characteristic polynomial while the maroots function will return the moving average roots from the MA characteristic polynomial. Both functions take an Arima object as their only argument. If a seasonal ARIMA model is passed, the roots from both polynomials are computed in each case.

The plot.armaroots function will plot the inverse of the roots on the complex unit circle. A causal invertible model should have all the roots outside the unit circle. Equivalently, the inverse roots should like inside the unit circle.

Here are a couple of examples demonstrating their use.

A simple example with three AR roots:



A more complicated example with ten AR roots and four MA roots. (This is not actually the best model for these data.)

fit <- Arima(woolyrnq,order=c(2,0,0),seasonal=c(2,1,1))
plot(arroots(fit),main="Inverse AR roots")
plot(maroots(fit),main="Inverse MA roots")


Finally, here is an example where two inverse roots lie outside the unit circle (shown in red).



Note that the Arima function will never return a model with inverse roots outside the unit circle. The auto.arima function is even stricter and will not select a model with roots close to the unit circle either, as such models are unlikely to be good for forecasting.

I won’t add these functions to the forecast package as I don’t think enough people would use them, and the package is big enough as it is. So I’m making them available here instead for anyone who wants to use them.

To leave a comment for the author, please follow the link and comment on their blog: Hyndsight » R. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)