# Durbin-Watson test for residuals of SARIMA(1,1,1) in R

I'm modelling a time series data using ARIMA. Now, I'm trying to test for the serial correlation of my model SARIMA(1,1,1) using the durbin watson test.

My problem is that I don't know what linear model I would put on the formula of the dwtest function in R. Here's the usage of the function,

dwtest(formula, order.by = NULL, alternative = c("greater", "two.sided", "less"),
iterations = 15, exact = NULL, tol = 1e-10, data = list())


Here's my code below,

library(forecast)
library(lmtest)
ChickenProd <- ts(ChickenProd, start = 1980, frequency = 4)
SARIMA111 <- Arima(ChickenProd, seasonal = list(order = c(1,1,1), period = 4))


The residuals of my model SARIMA111 is obtain by

SARIMA111[["residuals"]]


Now, I want to test the serial correlation of it using the Durbin-Watson test, but I don't know what linear model I would use in the formula argument of dwtest function in R. Is it the SARIMA(1,1,1) model? If so, how will I extract the coefficients of the SARIMA(1,1,1) model, and make a linear model formula in R?

I'm not sure how you would use the function with an ARIMA model - it requires a linear model object. Fortunately, the test is really simple to set up without the function.

Your test statistic (d) would be

   d = sum((SARIMA111$residuals - lag(SARIMA111$residuals))^2, na.rm = TRUE) /
sum(SARIMA111\$residuals^2, na.rm = TRUE)


That worked for an AR model that I had (I got d = 1.535959 with my data), so I hope it works for you. You'll have to look up this value in a DW table.

The na.rm = TRUE option is necessary because the first value of the residuals is NA.

• Thank you so much wcampbell, I was trying to make a test statistic (d), but not sure how to shift back the time for the residuals. And you just give me the answer - lag function. For an AR, it uses a linear model object too for the dwtest. Sep 28, 2012 at 23:35
• The Durbin-Watson test stat starts its summation from t=2 to t=T, in the function you've given it seems there is no restriction in the numerator for the sum function to start on the time t=2? Take a look on the test stat of the durbin-watson here. I'm just trying to make sure that the formula you've given to me is correct. Thank you. Sep 29, 2012 at 0:36
• Ok I got it, it's correct! Sep 29, 2012 at 0:59