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
Best Answer
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.You get the standardized residuals as follows:
fit1@mfit$stdresid
wherefit1
is an object of classDCCfit
. 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.)