Multidimensional GARCH (1,1) in R

I use R to evaluate the multidimensional GARCH (1,1) model for 4 time series. I tried this with the rmgarch package. It looks like I'm using it wrong, but I don't know what my mistake is. First time.

library(quantmod)
library(fBasics)
library(rmgarch)
#load data, time series closing prices, 10 year sample
#DAX 30
getSymbols('^GDAXI', src='yahoo', return.class='ts',from="2005-01-01",    to="2015-01-31")
GDAXI.DE=GDAXI[ , "GDAXI.Close"]
#S&P 500
getSymbols('^GSPC', src='yahoo', return.class='ts',from="2005-01-01", to="2015-01-31")
GSPC=GSPC[ , "GSPC.Close"]
#Credit Suisse Commodity Return Strat I
getSymbols('CRSOX', src='yahoo', return.class='ts',from="2005-01-01", to="2015-01-31")
CRSOX=CRSOX[ , "CRSOX.Close"]
#iShares MSCI Emerging Markets
getSymbols('EEM', src='yahoo', return.class='ts',from="2005-01-01", to="2015-01-31")
EEM=EEM[ , "EEM.Close"]
#calculating log returns of the time series
log_r1=diff(log(GDAXI.DE[39:2575]))
log_r2=diff(log(GSPC))
log_r3=diff(log(CRSOX))
log_r4=diff(log(EEM))
#return vector
r_t=cbind(log_r1, log_r2,log_r3, log_r4)
#specifying and fitting the model
model = multispec(replicate(4, ugarchspec(variance.model = c(1,1))))
model_order = mgarchspec(model, Order = c(1, 1), distribution ='mvnorm')
fit = mgarchfit(model_order, data = r_t, solver = 'solnp',fit.control =    list(eval.se = TRUE))
print(fit.1)
+4
source share
1 answer

below you will find a parallel implementation of the multidimensional DCC and ADCC Garch models. It is not clear what you are trying to achieve, but I assume that you are looking for some kind of correlation between each of the variables. Or at least an uncorrelated indicator of volatility. My code is based on the code that can be found here: "Multivariate implementation of Garch . " I highly recommend reading this.

Download all your TV shows as before

library(rmgarch)
library(parallel)
library(quantmod)

Dat<-data.frame(GDAXI.DE[-c(1:22)],GSPC,CRSOX,EEM)
Dat<-apply(Dat,2,function(x) Delt(x,k=1,type="log"))

garch . DCC-GARCH, DCC-GARCH

xspec = ugarchspec(mean.model = list(armaOrder = c(1, 1)), variance.model = list(garchOrder = c(1,1), model = 'sGARCH'), distribution.model = 'norm')
uspec = multispec(replicate(4, xspec))
spec1 = dccspec(uspec = uspec, dccOrder = c(1, 1), distribution = 'mvnorm')
spec1a = dccspec(uspec = uspec, dccOrder = c(1, 1), model='aDCC', distribution = 'mvnorm')

. , rmgarch . , ,

cl = makePSOCKcluster(4)
multf = multifit(uspec, Dat, cluster = cl)

fit1 = dccfit(spec1, data = Dat, fit.control = list(eval.se = TRUE), fit = multf, cluster = cl)
fit_adcc = dccfit(spec1, data = Dat, fit.control = list(eval.se = TRUE), fit = multf, cluster = cl)
print(fit1)           
print(fit_adcc)

stopCluster(cl)

, , !

+5

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


All Articles