4
$\begingroup$

I fit a simple linear model $y = bX$ to a data set today, and that produced 24 residuals (I have 24 data points, one for each year from 1984-2007). I would like to test the time-independence of the residuals of my model, and I was recommended by my supervisor to use the Ljung-Box test. The Box.test function in R takes 4 arguments:

  • x: a numeric vector or univariate time series.
  • lag: the statistic will be based on lag autocorrelation coefficients.
  • type: test to be performed: partial matching is used.
  • fitdf: number of degrees of freedom to be subtracted if x is a series of residuals.

What does lag mean, and what value would you guys recommend I use for the test? Also, what does fitdf represent, and what would the value for that parameter be in my case? Finally, the value of x is a vector of my 24 residuals, correct?

$\endgroup$
3
$\begingroup$

The Ljung-Box test is a test for significant autocorrelation in a stationary time series. For stationary time series the joint distribution of $X_i$ and $X_j$ for the series (in your case the residual series) only depends on the time difference $i-j$. This difference is called the lag. The correlation between $X_i$ and $X_j$ over all lags $i-j$ is called the autocorrelation function. Tests like Ljung-Box are testing to see if one or more of the lagged correlations is significantly different from 0. The term fitdf stands for degrees of freedom for the fit. The statistic involves several lagged correlation estimates and has a chi square distribution with l degrees of freedom under the null hypothesis that none of the correlations differ from 0 where l is the number of lagged correlation estimates used in the test statistic. It is most commonly used to check the adequacy of an ARIMA model by testing the model residuals for autocorrelation. Rejecting the null hypothesis would be an indication of model inadequacy.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ so my lag parameter would be 24 (the number of years), and my fitdf would be the degrees of freedom of my linear model? $\endgroup$ – Steven Jun 26 '12 at 20:42
  • $\begingroup$ No there are 24 lag parameters running from 1 to 24. But you would not necessarily use all 24 in computing the Ljung-Box test because you need areasoanble number of point in the computation of each lagged correlation estimate. The degrees of freedom for the Ljung-Box test would be the number of lagged correlations used in the formula. It would be something less than 24. I am not sure if fitdf refers to that or not. $\endgroup$ – Michael R. Chernick Jun 26 '12 at 21:02
0
$\begingroup$

The Ljung_Box statistic premises that the mean of the residuals is zero for all sub intervals. Thus if there is 1 pulse in the residuals the test is invalid. If the mean of the residuals for the first half (portion) is significantly different from the second half (portion) the test is invalid. If the variance of the errors changes over time the test is invalid. If the model parameters change over time the test is invalid. Good luck ! The whole idea of the null hypothesis underlying the LB test rests on the assumption that the errors from the model are Gaussian.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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