2013-06-01 90 views
5

第一次問一個問題在這裏,我會盡我所能,是明確的 - 但讓我知道我是否應該提供更多的信息!其次,這是一個很長的問題......希望可以簡單地爲某人解決;)!因此,使用「R」,我基於一些論文對多元GARCH模型進行建模(Manera et al。2012)。的R - 建模多元GARCH(rugarch和ccgarch)

我的常數條件相關(CCC)和動態條件相關(DCC)模式與所述平均值方程外部迴歸量模型;對於具有外部迴歸器的單變量GARCH和對於CCC/DCC模型使用「ccgarch」包(版本0.2.0-2),將「R」版本3.0.1與包「rugarch」版本1.2-2一起使用。 (我目前正在進入「rmgarch」包 - 但它似乎只爲DCC,我需要CCC模型了。)

我在模型的平均方程有問題。在上面提到的論文中,CCC和DCC模型之間的平均方程的參數估計發生了變化!我不知道我會怎麼做... (目前,看谷歌和Tsay的書「金融時間序列分析」和Engle的書「預測相關性」,以找到我的錯誤)

我的意思是「我的平均方程式在CCC和DCC模型之間不會改變」,它如下所示:我使用包rug rug指定n = 5時間序列的單變量GARCH。然後,我使用GARCH(ARCH + GARCH terms)的估計參數,並將它們用於CCC和DCC函數「eccc.sim()」和「dcc.sim()」。然後,從eccc.estimation()和dcc.estimation()函數中,我可以檢索方差方程以及相關矩陣的估計值。但不是平均等式。

我發佈R-代碼(可重複的和我原來的一個)的單變量模型中,只有CCC模型。謝謝你閱讀我的文章!!!!!

注意:在下面的代碼,「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) 

回答

3

您是否知道有對多元GARCH模型整體打包rmgarch

每它的描述,它涵蓋

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

+0

感謝您的回答!我實際上意識到這一點。但不幸的是,我需要CCC模型(至少從我在幫助文件中看到的rmgarch軟件包的小插圖中)可以看出。 – cmembrez

+0

我將簡單地使用CCC模型的ccgarch包和DCC模型的rmgarch。感謝您的輸入 – cmembrez