5
$\begingroup$

I am learning about time series analysis and want to perform Box-Ljung tests of the residuals of my fitted models, e.g.

Box.test(res, lag=h, fitdf=K, type = "Lj") 

However, I cannot find a way to calculate $K$. The only heuristics I have thus far are:

  • $K$ is equal to the number of parameters in the model.
  • If the residuals are calculated on raw data, $K = 0$.
  • If the model has no parameters, $K = 0$.

I found a formula for the number of parameters in a non-seasonal ARIMA model for a time series, stating $n = p + q + k + 1$, where $k$ is an indicator function for the constant $c$, that is, $c = k = 0$ if $d \ge 1$, but in the examples I have found, this formula doesn't agree with the $K$ used in the Box-Ljung test.

Can anybody help me count the parameters?

$\endgroup$
0

2 Answers 2

4
$\begingroup$

So, assuming you use ARIMA, the following applies:

1) when you have a model without differencing i.e. $ARIMA(p,d=0,q)$, then $K=p+q+1$, the $1$ comes from the model constant.

2) when you have a model $ARIMA(p,d>0,q)$, then $K=p+q$

You could look at prof. Hyndman's online free textbook

$\endgroup$
3
  • $\begingroup$ Where is the error variance? $\endgroup$
    – Aksakal
    Feb 3, 2015 at 13:45
  • $\begingroup$ Well, the idea, for correcting the degrees of freedom for the autocorrelation of the residuals, is precisely because of the discrepancy between the true white noise vs residual autocorrelations. $\endgroup$ Feb 3, 2015 at 13:59
  • $\begingroup$ @Deylan, I have those heuristics from the book you suggest. I decided to ask here because they don't agree with the tests he uses in his examples. However, it seems that the problem is the last +1 for the variance parametre, which is not counted in the Box-Ljung tests. I have notified the professor, who replied that it will be made more clear in future editions of the book. $\endgroup$
    – SiKiHe
    Feb 4, 2015 at 7:28
2
$\begingroup$

The help file for Box.test function in R states These tests are sometimes applied to the residuals from an ARMA(p, q) fit, in which case the references suggest a better approximation to the null-hypothesis distribution is obtained by setting fitdf = p+q, provided of course that lag > fitdf. Thus the suggestion is to use $K=p+q$ for an ARMA(p,q) model.

Conceptually, the key question is what the null distribution of the test statistic is given the model specification (and the implications on model residuals which are supplied for the Ljung-Box test). Note that the effective degrees of freedom to be used in a particular test depends on the test, not only on the model that generated the residuals. That is why, for example, you are not counting the estimated variance when you think of Ljung-Box test even though variance is a parameter of the model. Another example: in testing for remaining ARCH effects in GARCH model residuals using ARCH-LM test you discard the count of ARMA parameters but do count the GARCH parameters.

Hyndman and Athana­sopou­los textbook chapter about Ljung-Box test can be found here.

$\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.