【问题标题】:R - Modelling Multivariate GARCH (rugarch and ccgarch)R - 多元 GARCH 建模(rugarch 和 ccgarch)
【发布时间】:2013-06-01 15:38:11
【问题描述】:

第一次在这里提出问题,我会尽力明确 - 但如果我应该提供更多信息,请告诉我!其次,这是一个很长的问题......希望为某人解决简单;)!所以使用“R”,我根据一些论文(Manera et al. 2012)对多元 GARCH 模型进行建模。

我在均值方程中使用外部回归器对恒定条件相关 (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 的“动物园”对象(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)

【问题讨论】:

    标签: r time-series multivariate-testing volatility


    【解决方案1】:

    你知道有一个完整的包rmgarch 用于多元 GARCH 模型吗?

    根据其描述,它涵盖了

    可行的多元 GARCH 模型,包括 DCC、GO-GARCH 和 Copula-GARCH。

    【讨论】:

    • 感谢您的回答!我其实很清楚。但不幸的是,我需要不包括在内的 CCC 模型(至少,从我在帮助文件中看到的 rmgarch 包的小插图中)。
    • 我将简单地将 ccgarch 包用于 CCC 模型,将 rmgarch 用于 DCC 模型。感谢您的意见
    【解决方案2】:

    好吧,我希望这还不算太晚。这是我从rmgarch 手册中找到的:“CCC 模型是使用静态 GARCH copula (Normal) 模型计算的”。

    【讨论】:

    • 欢迎来到 Stack Overflow。在回答已被接受的旧问题(寻找绿色✓)之前,请确保您的答案添加了新内容或对它们有帮助。这是How to Answer 的指南。
    猜你喜欢
    • 2018-05-10
    • 1970-01-01
    • 2018-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多