# Help with the Ljung-Box test for time independence of residuals

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?

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.