5
$\begingroup$

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,

Data: http://iitstat.weebly.com/uploads/7/3/4/0/7340846/chickenprod.rdata

To download the data just right click the link and click "Save Link As..."

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?

Thank you in Advance!

$\endgroup$

1 Answer 1

5
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$ Sep 28, 2012 at 23:35
  • $\begingroup$ 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. $\endgroup$ Sep 29, 2012 at 0:36
  • $\begingroup$ Ok I got it, it's correct! $\endgroup$ Sep 29, 2012 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.