R - Modeling a multidimensional GARCH (rugarch and ccgarch)

For the first time, asking a question here, I will do my best to be explicit - but let me know if I have to provide more information! Secondly, this long question ... I hope, just solve for someone;)! Therefore, using "R", I model multidimensional GARCH models based on some articles (Manera et al., 2012).

I model models of constant conditional correlation (CCC) and dynamic conditional correlation (DCC) with external regressors in medium equations; using version "R" version 3.0.1 with the package "rugarch" version 1.2-2 for the one-dimensional GARCH with external regressors and the package "ccgarch" (version 0.2.0-2) for the CCC / DCC models. (I am looking at the "rmgarch" package now, but it seems to be only for DCC, and I need a CCC model too.)

I have a problem in the average equations of my models. The article I mentioned above evaluates estimates of the parameters of the average equation between the CCC and DCC models! And I don’t know how to do this in R ... (currently, looking at Google and Tsai’s book “analysis of financial time series” and Engle’s book “Pending correlations” to find my mistake)

What I mean by "my average equations do not change between CCC and DCC models" is this: I specify a one-dimensional GARCH for my n = 5 time series with the rugarch package. Then I use the parameters for evaluating the GARCH conditions (ARCH + GARCH) and use them for both the CCC functions and the DCC "eccc.sim ()" and "dcc.sim ()". Then, from the functions eccc.estimation () and dcc.estimation (), we can obtain estimates for the dispersion equations as well as correlation matrices. But not for the average equation.

I host the R code (reproducible and my original) for one-dimensional models and only for the CCC model. Thanks for reading my post !!!!!

Note: in the code below, "data.repl" is the object of the "zoo" dim 843x22 (9 series of daily goods return series and explanatory variables). Multidimensional GARCH is for 5 series only.

Playable Code:

# libraries: library(rugarch) library(ccgarch) library(quantmod) # Creating fake data: dataRegr <- matrix(rep(rnorm(3149, 11, 1),1), ncol=1, nrow=3149) dataFuelsLag1 <- matrix(rep(rnorm(3149, 24, 8),2), ncol=2, nrow=3149) #S&P 500 via quantmod and Yahoo Finance T0 <- "2000-06-23" T1 <- "2012-12-31" getSymbols("^GSPC", src="yahoo", from=T0, to=T1) sp500.close <- GSPC[,"GSPC.Close"], getSymbols("UBS", src="yahoo", from=T0, to=T1) ubs.close <- UBS[,"UBS.Close"] dataReplic <- merge(sp500.close, ubs.close, all=TRUE) dataReplic[which(is.na(dataReplic[,2])),2] <- 0 #replace NA ### (G)ARCH modelling ### ######################### # External regressors: macrovariables and all fuels+biofuel Working T index ext.regr.ext <- dataRegr regre.fuels <- cbind(dataFuelsLag1, dataRegr) ### spec of GARCH(1,1) spec with AR(1) ### garch11.fuels <- as.list(1:2) for(i in 1:2){ garch11.fuels[[i]] <- ugarchspec(mean.model = list(armaOrder=c(1,0), external.regressors = as.matrix(regre.fuels[,-i]))) } ### fit of GARCH(1,1) AR(1) ### garch11.fuels.fit <- as.list(1:2) for(i in 1:2){ garch11.fuels.fit[[i]] <- ugarchfit(garch11.fuels[[i]], dataReplic[,i]) } ################################################################## #### CCC fuels: with external regression in the mean eqaution #### ################################################################## nObs <- length(data.repl[-1,1]) coef.unlist <- sapply(garch11.fuels.fit, coef) cccFuels.a <- rep(0.1, 2) cccFuels.A <- diag(coef.unlist[6,]) cccFuels.B <- diag(coef.unlist[7, ]) cccFuels.R <- corr.test(data.repl[,fuels.ind], data.repl[,fuels.ind])$r # model=extended (Jeantheau (1998)) ccc.fuels.sim <- eccc.sim(nobs = nObs, a=cccFuels.a, A=cccFuels.A, B=cccFuels.B, R=cccFuels.R, model="extended") ccc.fuels.eps <- ccc.fuels.sim$eps ccc.fuels.est <- eccc.estimation(a=cccFuels.a, A=cccFuels.A, B=cccFuels.B, R=cccFuels.R, dvar=ccc.fuels.eps, model="extended") ccc.fuels.condCorr <- round(corr.test(ccc.fuels.est$std.resid, ccc.fuels.est$std.resid)$r,digits=3) 

My source code:

 ### (G)ARCH modelling ### ######################### # External regressors: macrovariables and all fuels+biofuel Working T index ext.regr.ext <- as.matrix(data.repl[-1,c(10:13, 16, 19:22)]) regre.fuels <- cbind(fuel.lag1, ext.regr.ext) #fuel.lag1 is the pre-lagged series ### spec of GARCH(1,1) spec with AR(1) ### garch11.fuels <- as.list(1:5) for(i in 1:5){ garch11.fuels[[i]] <- ugarchspec(mean.model = list(armaOrder=c(1,0), external.regressors = as.matrix(regre.fuels[,-i]))) }# regre.fuels[,-i] => "-i" because I model an AR(1) for each mean equation ### fit of GARCH(1,1) AR(1) ### garch11.fuels.fit <- as.list(1:5) for(i in 1:5){ j <- i if(j==5){j <- 7} #because 5th "fuels" is actually column #7 in data.repl garch11.fuels.fit[[i]] <- ugarchfit(garch11.fuels[[i]], as.matrix(data.repl[-1,j]))) } #fuelsLag1.names <- paste(cmdty.names[fuels.ind], "(-1)") fuelsLag1.names <- cmdty.names[fuels.ind] rowNames.ext <- c("Constant", fuelsLag1.names, "Working T Gasoline", "Working T Heating Oil", "Working T Natural Gas", "Working T Crude Oil", "Working T Soybean Oil", "Junk Bond", "T-bill", "SP500", "Exch.Rate") ic.n <- c("Akaike", "Bayes") garch11.ext.univSpec <- univ.spec(garch11.fuels.fit, ols.fit.ext, rowNames.ext, rowNum=c(1:15), colNames=cmdty.names[fuels.ind], ccc=TRUE) ################################################################## #### CCC fuels: with external regression in the mean eqaution #### ################################################################## # From my GARCH(1,1)-AR(1) model, I extract ARCH and GARCH # in order to model a CCC GARCH model: nObs <- length(data.repl[-1,1]) coef.unlist <- sapply(garch11.fuels.fit, coef) cccFuels.a <- rep(0.1, length(fuels.ind)) cccFuels.A <- diag(coef.unlist[17,]) cccFuels.B <- diag(coef.unlist[18, ]) #based on Engle(2009) book, page 31: cccFuels.R <- corr.test(data.repl[,fuels.ind], data.repl[,fuels.ind])$r # model=extended (Jeantheau (1998)) # "allow the squared errors and variances of the series to affect # the dynamics of the individual conditional variances ccc.fuels.sim <- eccc.sim(nobs = nObs, a=cccFuels.a, A=cccFuels.A, B=cccFuels.B, R=cccFuels.R, model="extended") ccc.fuels.eps <- ccc.fuels.sim$eps ccc.fuels.est <- eccc.estimation(a=cccFuels.a, A=cccFuels.A, B=cccFuels.B, R=cccFuels.R, dvar=ccc.fuels.eps, model="extended") ccc.fuels.condCorr <- round(corr.test(ccc.fuels.est$std.resid, ccc.fuels.est$std.resid)$r,digits=3) colnames(ccc.fuels.condCorr) <- cmdty.names[fuels.ind] rownames(ccc.fuels.condCorr) <- cmdty.names[fuels.ind] lowerTri(ccc.fuels.condCorr, rep=NA) 
+4
source share
1 answer

Did you know that there is a whole rmgarch package for multidimensional GARCH models?

According to the DESCRIPTION, it covers

Possible multidimensional GARCH models, including DCC, GO-GARCH and Bundle-GARCH.

+2
source

Source: https://habr.com/ru/post/1483950/


All Articles