[R] question about the results given by the Box.test?

oliver wee islandboy1982 at yahoo.com
Wed Feb 15 12:20:27 CET 2006


Hello, I am using the Ljung Box test in R to compute
if the resiudals of my fitted model is random or not.

I am not sure though what the results mean, I have
looked at various sources on the internet and have
come up with contrasting explanations (mainly because
these info deal with different program languages, like
SAS, SPSS, etc).

I know that my residuals should appropriate white
noise( is random) since a check of its ACF shows it to
be so (signifant correlation only at lag 1, decays
very quickly to zero).

But I am not sure how to interpret the ljung-box
result given by R.

To check for randomness of residuals, should the
p-value be small or large? How small and how large?
And at what lags should I check for the randomness of
the residuals? Is a p-value > 0.05 (or < 0.05) enough?
What if I have a very large p-value of 0.9796 at lag
1, but its value is 0.0139 at lag 8? 

For example, here's what I got for the first 10 lags
of the residuals I'm testing:
-------------------
 Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =1)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 7e-04, df = 1, p-value = 0.9796

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =2)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 0.1088, df = 2, p-value = 0.947

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =3)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 1.4179, df = 3, p-value = 0.7014

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =4)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 3.866, df = 4, p-value = 0.4244

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =5)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 6.0251, df = 5, p-value = 0.3038

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =6)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 12.11, df = 6, p-value = 0.05956

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =7)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 13.0307, df = 7, p-value = 0.07137

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =8)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 19.1766, df = 8, p-value = 0.01394

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =9)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 19.6753, df = 9, p-value = 0.02003

> Box.test(SP500DataSetFitMA2$residuals, type =
"Ljung", lag =10)

        Box-Ljung test

data:  SP500DataSetFitMA2$residuals 
X-squared = 19.7124, df = 10, p-value = 0.03209

--------------

I know this is not really a programming question, so I
apologize if it is inappropriate or if the question is
too elementary.

Thank you very much for your help.




More information about the R-help mailing list