Flexible Handling of Multivariate Mean Model

Discussions of ARCH, GARCH, and related models
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Flexible Handling of Multivariate Mean Model

Unread post by TomDoan »

If you need to estimate a multivariate GARCH model by maximum likelihood because of some non-standard treatment of the GARCH part of the model, but you have a relatively straightforward linear model for the means, you can handle that flexibly using models and equations. This is taken from the Elder Serletis JMCB 2010 example http://www.estima.com/forum/viewtopic.php?f=8&t=1189 with parts of this having to do with the GARCH elements removed to focus only on the mean model.

Code: Select all

open data "Elder_Serletis_oil_prices_Real_GDP.txt"
calendar(q) 1974:2
data(format=free,org=columns) 1974:02 2008:01 date oilgrow gdpgrow
*
compute nlags=4
set sqrthoil = 0.0
*
* Set up the VAR including the square root of oil (which will be
* generated recursively) as one of the regressors.
*
system(model=basevar)
variables oilgrow gdpgrow
lags 1 to nlags
det constant sqrthoil
end(system)
*
* Estimate the OLS VAR
*
estimate(resids=u)
compute gstart=%regstart(),gend=%regend()
*
* YVEC evaluates at T to the dependent variables
*
dec series[symm] uu hh
dec series[vect] yvec
gset yvec = ||oilgrow,gdpgrow||
*
gset uu = %sigma
gset hh = %sigma
*
* GARCHMEQNS are the VAR equations and BVEC are the coefficient vectors. 
* BVEC will adjust in size to match the equations, so if you change the number
* of lags in the VAR, these will be redimensioned automatically. The BVEC array
* will be put into the parameter set.
*
 dec vect[equation] garchmeqns(%nvar)
dec vect[vect] bvec(%nvar)
dec vect[vect] garchp(%nvar)
do i=1,%nvar
   compute garchmeqns(i)=%modeleqn(basevar,i)
   compute bvec(i)=%eqncoeffs(garchmeqns(i))
end do i
**********************************************************************
*
* This returns the explanatory part of the mean model at <<time>>, evaluated
* at the current setting for BVEC.
*
function %%garchmu time
type vector %%garchmu
type integer time
*
dim %%garchmu(%nvar)
do i=1,%nvar
   compute %%garchmu(i)=%eqnvalue(garchmeqns(i),time,bvec(i))
end do i
end
*
* We've taken out the definition of %%GARCHH, which is what would be the
* part that would be most specific to your application. This also uses
* the sqrthoil as a recursively generated GARCH-M term, which won't
* be present in most models. And the rotation by BB is also specific
* to the Elder-Serletis model. A more general setup would have
*
* frml garchlogl = hh=calculation for current variance,$
*  ux=yvec(t)-%%garchmu(t),uu=%outerxx(ux),%logdensity(hh,ux)
*
frml garchmlogl = hh=%%garchh(t),sqrthoil=sqrt(hh(t)(1,1)),$
   ux=bb*yvec(t)-%%garchmu(t),uu=%outerxx(ux),%logdensity(hh,ux)
*
nonlin(parmset=meanparms) bvec
nonlin(parmset=garchparms) the parameters governing the GARCH model
*
maximize(parmset=meanparms+garchparms) ...
Post Reply