第一次在这里提出问题时,我会尽力做到明确-但请告知我是否应该提供更多信息!其次,这是一个漫长的问题...希望很容易为某人解决;)!因此,我使用“R”基于某些论文对多元GARCH模型进行建模(Manera等人,2012年)。

我用均值方程中的外部回归模型对恒定条件相关(CCC)和动态条件相关(DCC)模型进行建模。对于带有外部回归变量的单变量GARCH,使用“R”版本3.0.1和“rugarch”版本1.2-2软件包,以及对于CCC/DCC模型使用“ccgarch”软件包(版本0.2.0-2)。 (我目前正在研究“rmgarch”软件包-但这似乎仅用于DCC,我也需要CCC模型。)

我的模型均值方程式有问题。在我上面提到的论文中,CCC和DCC模型之间的均值方程的参数估计值发生了变化!而且我不知道我将如何在R中做到这一点...
(目前,在Google上浏览Tsay的书“金融时间序列分析”和Engle的书“预测相关性”以发现我的错误)

我的意思是“我的平均方程在CCC和DCC模型之间不会改变”,它表示以下内容:我为带有打包rugarch的n = 5时间序列指定了单变量GARCH。然后,我使用GARCH的估算参数(ARCH + GARCH术语),并将其用于CCC和DCC函数“eccc.sim()”和“dcc.sim()”。然后,从eccc.estimation()和dcc.estimation()函数中,我可以获取方差方程以及相关矩阵的估计。但不是针对均值方程。

我仅针对单变量模型和CCC模型发布R代码(可复制的代码和我的原始代码)。已经感谢您阅读我的帖子!!!!

注意:在下面的代码中,“data.repl”是昏暗的843x22的“zoo”对象(9种每日商品返回系列和说明变量系列)。多元GARCH仅适用于5系列。

可复制的代码:

# 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's 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)

我的原始代码:
### (G)ARCH modelling ###
#########################
# External regressors: macrovariables and all fuels+biofuel Working's 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's T Gasoline", "Working's T Heating Oil",
              "Working's T Natural Gas", "Working's T Crude Oil",
              "Working's 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)

最佳答案

您是否知道针对多变量GARCH模型有一个完整的rmgarch软件包?

根据其说明,它涵盖了

关于R-建模多元GARCH(rugarch和ccgarch),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16874375/

10-12 22:38