# DCC GARCH model diagnostics in R

I have fitted a DCC GARCH model to my multivariate financial data. So, now I need to check the fitted model by using the standardized residual and its squared process. A good fitted model should have no serial correlation in the squared residuals, no ARCH effect and the residuals should be normally distributed. To check this, I need to use the ARCH-LM Test, Ljung-Box test and also Jarque-Bera test on the fitted model. Right? The problem is I do not know how to get the standardized residuals for my multivariate data.

Below is my reproducible code:

# load libraries
library(rugarch)
library(rmgarch)
library(FinTS)
library(tseries)

data(dji30retw)
Dat = dji30retw[, 1:8, drop = FALSE]
uspec = ugarchspec(mean.model = list(armaOrder = c(0,0)), variance.model = list(garchOrder = c(1,1), model = "sGARCH"),
distribution.model = "norm")
spec1 = dccspec(uspec = multispec( replicate(8, uspec) ), dccOrder = c(1,1),  distribution = "mvnorm")
fit1 = dccfit(spec1, data = Dat, fit.control = list(eval.se=T))
print(fit1)


I have tried the following, but I am not sure whether it is correct:

resid = residuals(fit1)/sd(residuals(fit1))
### test for arch effect using Lagrange multiplier (ARCH LM test)
ArchTest(resid,lag=12,demean=F)


Also, I have tried to use the Jarque-Bera and Ljung-Box test, but I am getting the following error:

Error in Box.test(resid^2, lag = 12, type = "Ljung") : x is not a vector or univariate time series


## 2 Answers

A good fitted model should have no serial correlation in the squared residuals, no ARCH effect and the residuals should be normally distributed.

The first two points are the same. However, ARCH-LM test is not suitable here because it assumes raw data rather than model residuals. For a univariate case, ARCH-LM test should be substituted by Li-Mak test when considering model residuals instead of raw data; however, I do not know if there exists an appropriate test in the multivariate case to substitute a multivariate ARCH-LM test. The critical values of the Ljung-Box test should also be adjusted for the fact that the test is applied on model residuals rather than raw data.

The last point depends on what assumption you used when specifying the model. The model may assume that standardized errors follow a multivariate normal distribution; then testing for normality makes sense. However, the model may assume a different multivariate distribution for the standardized errors, in which case testing for normality would not be logical. Since you used an argument distribution = "mvnorm" when specifying the DCC model, testing for normality is fine.

The problem is I do not know how to get the standardized residuals for my multivariate data.

You get the standardized residuals as follows: fit1@mfit\$stdresid where fit1 is an object of class DCCfit. Meanwhile, what you tried does not seem right since you are supposed to scale the residuals by the square root of the inverse of the estimated conditional variance matrix (which is part of the DCC model output), period by period.

Your problem with the Ljund-Box test seems to be that you are supplying an argument of a wrong type. Your model residuals will be a multivariate series while the Ljung-Box test is for a univariate series. You should either test each univariate series one by one or ideally look for a multivariate version of the test. (Remember to adjust the null distribution of the test statistic due to the fact that the test is applied on model residuals rather than raw data.)

• Thanks! Can I use MarchTest function from MTS package for the Multivariate ARCH LM test? And, how do I actually adjust the null distribution of the test statistics since I tested it on model residuals? – nsaa Jan 26 '16 at 17:47
• I am afraid the multivariate ARCH test (as well as the multivariate Ljung-Box test which is also available in the same MTS package) are directly suited for raw data rather than model residuals. Adjusting the null distribution may be tricky; actually, I am not aware of any theoretical work on the subject. However, there should be more information on the tests in Tsay's "Multivariate Time Series Analysis with R and Financial Applications" which I do not have access to... – Richard Hardy Jan 26 '16 at 18:18
• I would not be surprised if you were not able to do proper DCC model diagnostics because of the lack of appropriate tests, both in theory and of their implementations in statistical software. But I would certainly be interested to hear if you find some relevant material! – Richard Hardy Jan 26 '16 at 18:21
• For the Ljung–Box statistics of the residuals, we can use the function 'mq(resid, lag = 24, adj = 0)'. This is explained in Tsay's book, page 114-116. – nsaa Jan 26 '16 at 18:35
• I found Tsay's lecture notes in which he applies the tests in the MCHdiag function of the MTS package directly to model residuals, and I don't think (although I am not 100% sure) that there is an adjustment for the null distribution built into the function. (You can easily see the function code by typing MCHdiag and hitting Enter in R commander window; the function is entirely written in R.) As far as I understand, that is incorrect (believe it or not, there may be mistakes in textbooks!), but how severe the consequences may be is not clear. The same may be true for the Ljung-Box case. – Richard Hardy Jan 26 '16 at 18:41

Bauwens (2006) says that the Hosking test this test can be used to detect any misspecification in the conditional variance matrix Ht.

They also mention though, that: asymptotic distribution of the portmanteau statistics is, however, unknown in this case since the residuals have been estimated. Furthermore, ad hoc adjustments of degrees of freedom for the number of estimated parameters have no theoretical justiﬁcation. In such a case, portmanteau tests should be interpreted with care even if simulation results reported by Tse and Tsui (1999) suggest that they provide a useful diagnostic in many situations.