Multivariate GARCH(1,1) in R -


i use r estimate multivariate garch(1,1) model 4 time series. tried rmgarch package. seems i'm using wrong don't know mistake is. first time using.

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 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 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 , fitting 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) 

below find parallel implementation of multivariate dcc , adcc garch models. unclear trying achieve, assume looking kind of correlation between each of variables. or @ least uncorrelated measure of volatility. code based on code can found here:"multivariate garch implementation". highly recommend reading this.

load series before

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

ensure equal length of data , calculate log returns of time series

dat<-data.frame(gdaxi.de[-c(1:22)],gspc,crsox,eem) dat<-apply(dat,2,function(x) delt(x,k=1,type="log")) 

specify univariate garch process along multivariate model. here include both vanilla dcc-garch assymmetric dcc-garch model specification

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

when performing computationally intense models, recommend using parallel approach. luckily rmgarch has feature build in. so, lets open number of clusters want perform analysis on

cl = makepsockcluster(4) multf = multifit(uspec, dat, cluster = cl) 

we can fit model

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) 

it important remember close clusters using

stopcluster(cl) 

i hope helps in looking for!


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -