Over a million developers have joined DZone.

Plotting the characteristic roots for ARIMA models

DZone's Guide to

Plotting the characteristic roots for ARIMA models

· Big Data Zone ·
Free Resource

How to Simplify Apache Kafka. Get eBook.

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.

12 Best Practices for Modern Data Ingestion. Download White Paper.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}