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!
Best Answer
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
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.