Page 4 of 6

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sat Apr 05, 2014 10:13 am
Hi, thank you for your answer. Now, I'm asking some questions about my model. My goal is to analyse the evolution of the links between stock volatility and commodity volatility using a DCC GARCH model. So, what do I need to use ? The conditional correlations or the conditional variances ? How do we get these two things in the results of DCC GARCH model by using the add-in ?

Re: Dynamic conditional correlation multivariate GARCH

Posted: Sat Apr 05, 2014 11:28 am

Re: Dynamic conditional correlation multivariate GARCH

Posted: Fri May 02, 2014 8:40 am
Hi all,

I'm trying to use the A-DCC model posted in this thread and have adapted it to a bivariate case. I have one error that I do not know how to solve, or really what it means. When I run the model with certain initial values I get the error message "Overflow – Missing data generated in ”Series Q11F = QBAR …”. This does not happen for all initial values, but when this message does not appear I violate some of the conditions for the model and thus I believe I am on the right track with the initial values when the overflow message appears. Is there any obvious reason for why this might happen (something wrong with sample specification, missing terms in equation ..) ?

Any help is greatly apprecited.

Code: Select all

`'ADCC Model by Cappiello et al (2006) Bivariate'Load workfile and measure length of seriesseries obscount = 1scalar obslength = @sum(obscount)'Specify the return seriesseries y1 = goldbullionreturnseries y2 = sp500return'Specify the number of iterations in the MLE (Engle & Sheppard (2001) used just one iteration)!itermle = 1000'Specify the initial values of the parameterscoef(1) a11coef(1) a12coef(1) a22coef(1) b11coef(1) b12coef(1) b22coef(1) g11coef(1) g12coef(1) g22'Values may vary depending on which will result in the highest Likelihood valuea11(1) = 0.05a12(1) = 0.05a22(1) = 0.05b11(1) = 0.15b12(1) = 0.15b22(1) = 0.15g11(1) = 0.01g12(1) = 0.01g22(1) = 0.01'Setting the samplesample s0    @first+13 @lastsample s1    @first+14 @lastsample sf    @first+15 @lastsample sf_alt   @first+25 @last'Initialization at sample s0smpl s0'Each return series is modeled with their respective GARCH specifications:'Use Bollerslev-Wooldridge QML'Standard errorsequation eq1.arch(9,0,asy=0, egarch,m=1000,c=1e-5,h) y1 c y1(-12) 'res_s11_1000 @ res_s11_1000equation eq2.arch(2,1,asy=2, egarch,m=1000,c=1e-5,h) y2 c y2(-13) 'res_s22_1000 @ res_s22_1000'Make residual series   -- This is Uteq1.makeresids e1eq2.makeresids e2'Make a garch series from the univariate estimateseq1.makegarch h11eq2.makegarch h22'Normalizing the residuals from e to e* (named as "e1n" and "e2n")   -- Here we change from Ut to epsilon t. series e1n = e1/h11^0.5series e2n = e2/h22^0.5'Make residual series for asymmetries in DCC modelseries n1n = @recode(e1n<0,e1n*e1n,0)series n2n = @recode(e2n<0,e2n*e2n,0)'The Q_bar=E[en*en'] components and its sample equivalent series qbar11 = @mean(e1n*e1n)series qbar12 = @mean(e1n*e2n)series qbar21 = @mean(e2n*e1n)series qbar22 = @mean(e2n*e2n)'The N_barseries nbar11 = @mean(n1n*n1n)series nbar12 = @mean(n1n*n2n)series nbar21 = @mean(n2n*n1n)series nbar22 = @mean(n2n*n2n)'Initialize the elements of Qt for variance targetingseries q11 = @var(e1)series q12 = @cov(e1,e2)series q21 = @cov(e2,e1)series q22 = @var(e2)'***********************************************************************************************'Declare a Loglikelihood objectlogl dccdcc.append @logl logl'The elements of matrix Qtdcc.append  q11 = qbar11- ((a11(1)*qbar11 + a12(1)*qbar12)*a11(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a12(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b11(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b12(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g11(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g12(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a11(1)+e2n(-1)*a12(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g11(1)+n2n(-1)*g12(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b11(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b12(1))dcc.append  q12 = qbar12- ((a11(1)*qbar11 + a12(1)*qbar12)*a12(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a22(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b12(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b22(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g12(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g22(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b12(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b22(1))dcc.append  q21 = qbar12- ((a11(1)*qbar11 + a12(1)*qbar12)*a12(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a22(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b12(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b22(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g12(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g22(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b12(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b22(1))dcc.append  q22 = qbar22- ((a12(1)*qbar11 + a22(1)*qbar12)*a12(1) + (a12(1)*qbar12 +a22(1)*qbar22)*a22(1)) - ((b12(1)*qbar11 + b22(1)*qbar12)*b12(1) + (b12(1)*qbar12 +b22(1)*qbar22)*b22(1)) - ((g12(1)*nbar11 + g22(1)*nbar12)*g12(1) + (g12(1)*nbar12 +g22(1)*nbar22)*g22(1)) + (a12(1)*e1n(-1) + a22(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g12(1)*n1n(-1) + g22(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b12(1)*q11 + b22(1)*q12(-1))*b12(1) + (b12(1)*q12(-1) +b22(1)*q22(-1))*b22(1))'As input to detQQQdcc.append  q12n = (qbar12- ((a11(1)*qbar11 + a12(1)*qbar12)*a12(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a22(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b12(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b22(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g12(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g22(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b12(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b22(1)))/((abs(q11)^0.5)*(abs(q22)^0.5))dcc.append  q21n = (qbar12- ((a11(1)*qbar11 + a12(1)*qbar12)*a12(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a22(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b12(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b22(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g12(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g22(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b12(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b22(1)))/((abs(q22)^0.5)*(abs(q11)^0.5))'Setting up the Loglikelihood function, assuming that resid ~ N(0,H)   'The Loglikelihood function is L' = -0.5*{summation from t=1 to T of ([log of determinant of inverse(diag[Qt])*Qt*inverse(diag[Qt])] + [en'*inverse(diag[Qt])*Qt*inverse(diag[Qt])*en])'Taking the adjoint{inverse(diag[Qt])*Qt*inverse(diag[Qt])}dcc.append  detQQQ = 1 - q12n*q21n'Tomando el adjoint{inverse(diag[Qt])*Qt*inverse(diag[Qt])}dcc.append  cofact11 =   1*1dcc.append  cofact12 =(-1)*q21ndcc.append  cofact21 =(-1)*q12ndcc.append  cofact22 =   1*1'Taking the inverse{inverse(diag[Qt])*Qt*inverse(diag[Qt])}dcc.append  invQQQ11 = cofact11/detQQQdcc.append  invQQQ12 = cofact12/detQQQdcc.append  invQQQ21 = cofact21/detQQQdcc.append  invQQQ22 = cofact22/detQQQ'Taking the en'*inverse{inverse(diag[Qt])*Qt*inverse(diag[Qt])}*endcc.append  enQQQen11 = e1n*invQQQ11*e1ndcc.append  enQQQen12 = e1n*invQQQ12*e2ndcc.append  enQQQen21 = e2n*invQQQ21*e1ndcc.append  enQQQen22 = e2n*invQQQ22*e2n'Append the loglikelihood function'Instead of log(detQQQ) use log(abs(detQQQ))dcc.append logl = -0.5*(log(abs(detQQQ)) + (enQQQen11+enQQQen21+ enQQQen12+enQQQen22)  -(e1n^2 + e2n^2 + 2*e1n*e2n))'Specifies the sample data where the estimation will be madesmpl sf'Estimates the parameters now using BHHH algorithmdcc.ml(b, showopts, m=!itermle, c=1e-5) 'A detQQQnpd = 0 indicates detQQQ is positive definiteseries count = (detQQQ<=0)scalar detQQQnpd = @sum(count)'Display the estimated parametersshow dcc.output'Forecast the q's by initializing themseries  q11f = 0series  q12f = 0series  q21f = 0series  q22f = 0'Specify the sample period to be forecastedsmpl sfseries  q11f = qbar11- ((a11(1)*qbar11 + a12(1)*qbar12)*a11(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a12(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b11(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b12(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g11(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g12(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a11(1)+e2n(-1)*a12(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g11(1)+n2n(-1)*g12(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b11(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b12(1))series  q12f = qbar12- ((a11(1)*qbar11 + a12(1)*qbar12)*a12(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a22(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b12(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b22(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g12(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g22(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b12(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b22(1))series  q21f =qbar12- ((a11(1)*qbar11 + a12(1)*qbar12)*a12(1) + (a11(1)*qbar12 +a12(1)*qbar22)*a22(1)) - ((b11(1)*qbar11 + b12(1)*qbar12)*b12(1) + (b11(1)*qbar12 +b12(1)*qbar22)*b22(1)) - ((g11(1)*nbar11 + g12(1)*nbar12)*g12(1) + (g11(1)*nbar12 +g12(1)*nbar22)*g22(1)) + (a11(1)*e1n(-1) + a12(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g11(1)*n1n(-1) + g12(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b11(1)*q11(-1) + b12(1)*q12(-1))*b12(1) + (b11(1)*q12(-1) +b12(1)*q22(-1))*b22(1))series  q22f = qbar22- ((a12(1)*qbar11 + a22(1)*qbar12)*a12(1) + (a12(1)*qbar12 +a22(1)*qbar22)*a22(1)) - ((b12(1)*qbar11 + b22(1)*qbar12)*b12(1) + (b12(1)*qbar12 +b22(1)*qbar22)*b22(1)) - ((g12(1)*nbar11 + g22(1)*nbar12)*g12(1) + (g12(1)*nbar12 +g22(1)*nbar22)*g22(1)) + (a12(1)*e1n(-1) + a22(1)*e2n(-1))*(e1n(-1)*a12(1)+e2n(-1)*a22(1)) + (g12(1)*n1n(-1) + g22(1)*n2n(-1))*(n1n(-1)*g12(1)+n2n(-1)*g22(1)) + ((b12(1)*q11 + b22(1)*q12(-1))*b12(1) + (b12(1)*q12(-1) +b22(1)*q22(-1))*b22(1))'To plot the time-varying conditional correlationsmpl sf_altseries rt = q12f/(@sqr(q11f)*@sqr(q22f))graph rtgraph.line rtshow rtgraphdelete e1n e2ndelete q12n q21ndelete n1n n2ndelete qbar*delete xbar*delete cofact*delete enqqqen*delete invqqq*delete enqqqen*delete eigenvect*delete invqqq*show detqqqnpdseries eigminsscalar eigminfor !j = 16 to obslength   'Input the hijsim to the elements of a 2x2 Q matrix   sym(2) Q   Q(1,1) = q11f(!j)   Q(2,1) = q21f(!j)   Q(2,2) = q22f(!j)   'Take the eigenvalues of Q   vector(4) Qeigenval   Qeigenval = @eigenvalues(Q)   'Collect the min eigenvalues in each Qt   eigmins(!j) = @min(Qeigenval)nexteigmin = @min(eigmins)show eigmin`

Re: Dynamic conditional correlation multivariate GARCH

Posted: Fri May 23, 2014 8:27 am
Dear all,
a'm a new user of eviwes 5 an i'm trying to estimate a dcc bivariate Garch. I used the code that i found in this forum but it seems that there's something wrong because i have problems when i try to estimate the logl, the error message is:" missing values in @logl at current coefficients at observation 1/06/2003"
Can anyone help me please and tell me where did i go wrong?
thank you very much

'set sample range

sample s0 01/02/2003 12/31/2012
sample s1 01/03/2003 12/31/2013
scalar pi=3.14159

'defining the return series in terms of y1 and y2
series y1=rtsp
series y2=rtnasdaq

'fitting univariate GARCH(1,1) models to each of the two returns series
equation eq_y1.arch(1,1,m=1000,h) y1 c
equation eq_y2.arch(1,1,m=1000,h) y2 c

'extract the standardized residual series from the GARCH fit
eq_y1.makeresids(s) z1
eq_y2.makeresids(s) z2

'extract garch series from univariate fit
eq_y1.makegarch() garch1
eq_y2.makegarch() garch2

'Caculate sample variance of series z1, z2 and covariance of z1and z2 and correlation between z1 and z2
scalar var_z1=@var(z1)
scalar var_z2=@var(z2)
scalar cov_z1z2=@cov(z1,z2)
scalar corr12=@cor(z1,z2)

'defining the starting values for the var(z1) var(z2) and covariance (z1,z2)
series var_z1t=var_z1
series var_z2t=var_z2
series cov_z1tz2t=cov_z1z2

'declare the coefficient starting values
coef(2) T
T(1)=0.2
T(2)=0.7

' ...........................................................
' LOG LIKELIHOOD for correlation part
' set up the likelihood
' 1) open a new blank likelihood object and name it 'dcc'
' 2) specify the log likelihood model by append
' ...........................................................

logl dcc
dcc.append @logl logl

'specify var_z1t, var_z2t, cov_z1tz2t
dcc.append var_z1t=@nan(1-T(1)-T(2)+T(1)*(z1(-1)^2)+T(2)*var_z1t(-1),1)
dcc.append var_z2t=@nan(1-T(1)-T(2)+T(1)*(z2(-1)^2)+T(2)*var_z2t(-1),1)
dcc.append cov_z1tz2t=@nan((1-T(1)-T(2))*corr12+T(1)*z1(-1)*z2(-1)+T(2)*cov_z1tz2t(-1),1)

dcc.append pen=(var_z1t<0)+(var_z2t<0)

'specify rho12
dcc.append rho12=cov_z1tz2t/@sqrt(@abs(var_z1t*var_z2t))

'defining the determinant of correlation matrix and determinant of Dt
dcc.append detrRt=(1-(rho12^2))
dcc.append detrDt=@sqrt(garch1*garch2)
dcc.append pen=pen+(detrRt<0)
dcc.append detrRt=@abs(detrRt)

'define the log likelihood function
dcc.append logl=(-1/2)*(2*log(2*pi)+log(detrRt)+(z1^2+z2^2-2*rho12*z1*z2)/detrRt)-10*pen

'estimate the model
smpl s1
dcc.ml(showopts, m=500, c=1e-5)

'display output and graphs
show dcc.output
graph corr.line rho12
show corr

Dynamic conditional correlation multivariate GARCH

Posted: Thu Jun 12, 2014 7:29 am
Hi all
what does "h" means in equation eq_y1.arch(1,1,m=1000,h) y2 c?
how can I use restriction of IGARCH in model?
tnx alot

Re: Dynamic conditional correlation multivariate GARCH

Posted: Thu Jun 12, 2014 7:40 am
somi wrote:Hi all
what does "h" means in equation eq_y1.arch(1,1,m=1000,h) y2 c?
how can I use restriction of IGARCH in model?
tnx alot

Have you looked at the manual?
Chapter 7 of EViews User Guide II is devoted to ARCH and GARCH estimation.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Tue Mar 03, 2015 2:56 am
Hi, can someone provide the extended codes of DCC-GARCH for a 5 variable model? I used a code that is provided in this forum for a 5 variable model, but it doesnt produce the final result of the DCC-DARCH.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Tue Mar 03, 2015 6:48 pm
Hi all,
Currently I am trying to run a multivariate GARCH model spproach. But I still do not know the method run Multivariate models. Hope to get help from you. The model is attached below.I looking forward to find methods to run this model.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Mar 04, 2015 12:46 am
This is quite a specific version of Constant Conditional Correlation model, so you'll have to build a maximum likelihood model to estimate the parameters. It should be fairly easy to do that with the LogL object. There are also plenty of examples in the forum regarding ML estimation of multivariate GARCH models.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Mar 04, 2015 1:25 am
I'm still not clear steps build a maximum likelihood model to Estimate the parameters. So you can guide runs Model, because I do not know anything about how to run the model. Thank' you very much.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Wed Mar 04, 2015 1:34 am
I'm still not clear steps build a maximum likelihood model to Estimate the parameters. So you can guide runs Model, because I do not know anything about how to run the model. Thank' you very much.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Mon Jun 22, 2015 10:06 am
I can't quite understand how the likelihood function in the original code is specified. My algebra isn't that strong, so I'm trying to grasp it through looking at the articles and application code at the same time. Can anyone help me?

Code: Select all

`dcc.append logl=(-1/2)*(2*log(2*pi)+log(detrRt)+(z1^2+z2^2-2*rho12*z1*z2)/detrRt)-10*pen`

Looking at the paper by Engle (2002) I assume the model is not divided into volatility and correlation parts, but estimated as one single ML model. However comparing to eq (26) the second last equation, the above function is missing 2*log|Dt| - and I don't quite understand the -10*pen?

And I assume that (z1^2+z2^2-2*rho12*z1*z2)/detrRt is the non-matrix specification of the last term, i.e. e_t*R_t^-1*e_t. But in that case, it shouldn't be the determinant of Rt, but just Rt, shouldn't it?

Re: Dynamic conditional correlation multivariate GARCH

Posted: Thu Jul 09, 2015 2:24 pm
What is the most appropriate input to DCC GARCH- DLOG(series), Resid from ARMA modelling of dlog(series) or Resid from ARIMA modelling of price series?

While estimating DCC GARCH whether we should start with the dlog(series) and then estimate GARCH and DCC Counterpart OR we should do ARMA modelling of dlog(series) OR ARIMA modelling of price series, obtain the residuals , check diagnostics and then proceed to estimate GARCH and DCC Counterpart.
Additionally if out of the two series one reaches white noise by just doing dlog(series) and other requires ARMA modelling, then whether the following input can be given to DCC GARCH model or not - dlog(series1) and residual of ARMA modelling(series2).
And if Not , then what is the right way of proceeding further.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Thu Jul 09, 2015 2:25 pm
If we want to calculate time varying correlation between various asset class from 2006-2009 and if our purpose is not forecasting but analysis & inference based on historical data, then out of these two options which one is appropriate
1. Estimate the Univariate GARCH for the entire time span (2006-09) and from its residuals and conditional variance estimate Dynamic correlations.
Concern:
If we proceed like this, then since the residuals were estimated based on GARCH estimate of the entire sample (2006-09), therefore the time varying correlation, say for example in 2007 will be biased, since the residuals from which it is calculated has information till 2009. Ideally the time varying correlation in 2007 should be based only on the information available till 2007 not 2009.
2. Rolling window DCC GARCH: We should keep the window rolling either on daily basis or weekly basis and then re estimate entire model (GARCH, Residuals and DCC Counterpart) for daily rolling window or weekly rolling window.
Concern:
Since we want to analyse and inference from the data based on all the available historical data till date, so doesn’t make much sense and will just increase the volume of work.

Re: Dynamic conditional correlation multivariate GARCH

Posted: Thu Jul 30, 2015 8:04 am
misssing valeus in @logl series ?!!!