I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) like in (this) blog post by Dave Giles. In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Portmanteau Test (asymptotic) statistics for every defined VAR:


or Breusch-Godfrey LM test:

serial.test(VAR, type="BG")
  1. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - performs the Durbin-Watson test:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - performs the Breusch-Godfrey zest:

    bgtest(res_data[,1] ~ res_data[,2])


  • Do I approach the test correctly (especially, not selecting a lag after the VAR was defined with a lag already)?
  • What would you recommend to do?
  • Can you confirm that Box.test() does not work with VAR?

1 Answer 1


serial.test from the "vars" package should be sufficient for your purposes. It offers either a multivariate Ljung-Box test* (when type=PT.asymptotic or type=PT.adjusted) or a multivariate Breusch-Godfrey test (when type=BG or type=ES).

DW test is less general and less powerful than BG test (see Wikipedia). Univariate tests (e.g. univariate BG test) applied on each univariate series do not assess the whole autocovariance matrix of a multivariate error process but rather just its diagonal elements.

In summary, the options available from serial.test are both rich enough (both LB and BG) and, being multivariate, more comprehensive than the univariate alternatives.

*I am not 100% sure, but I think the Portmanteau test in serial.test is the multivariate version of the vanilla Ljung-Box test, which itself is a Portmanteau test.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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