|
Statistics and Algorithms / GARCH Models / GARCH Models (Multivariate) / MV GARCH Extensions |
If you want to estimate a GARCH model which doesn’t fit into the forms given by GARCH, you can use MAXIMIZE instead. The setup for this follows the same steps as it does for a univariate model, but all the steps are more complicated because of the need to deal with matrices rather than scalars. The task is usually easier if you write it specifically for two variables. If you need to allow for three or more, it makes more sense to write it very generally (as is done here) rather than expanding out terms.
This shows the code for estimating a standard GARCH(1,1) model and a CC. For most variations, all you would typically need to do is to have an alternative FRML for HF. In this case, HF is easy to write as a simple FRML evaluating to a SYMMETRIC array, but remember that, if the calculation is more complicated, you can use a FUNCTION as is done with the CC model.
This is from example file GARCHMVMAX.RPF. Note that it takes about four times as long to estimate a model this way as it does a similar model done with GARCH.
The initial few lines of this set the estimation range, which needs to be done explicitly, and the number of variables. Then, vectors for the dependent variables, residuals and residual formulas are set up. The SET instructions copy the dependent variables over into the slots in the vector of series.
compute gstart=2,gend=6237
compute n=3
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = xjpn
set y(2) = xfra
set y(3) = xsui
This is specific to a mean-only model. It sets up the formulas (the &i are needed in the formula definitions when the FRML is defined in a loop), and estimates them using NLSYSTEM. This both initializes the mean parameters, and computes the unconditional covariance matrix. If you want more general mean equations, the simplest way to do that would be to define each FRML separately.
dec vect b(n)
nonlin(parmset=meanparms) b
do i=1,n
frml resid(i) = (y(&i)-b(&i))
end do i
nlsystem(parmset=meanparms,resids=u) gstart gend resid
compute rr=%sigma
The paths of the covariance matrices and UU are saved in the SERIES[SYMM] named H and UU. UX and HX are used to pull in residuals and H matrices.
declare series[symm] h uu
declare symm hx(n,n)
declare vect ux(n)
These are used to initialize pre-sample variances.
gset h * gend = rr
gset uu * gend = rr
This is a standard (normal) log likelihood formula for any multivariate GARCH model. The difference among these will be in the definitions of HF and RESID. The function %XT pulls information out of a matrix of SERIES.
declare frml[symm] hf
frml logl = $
hx = hf(t) , $
%do(i,1,n,u(i)=resid(i)) , $
ux = %xt(u,t), $
h(t)=hx, uu(t)=%outerxx(ux), $
%logdensity(hx,ux)
DVECH Model
This creates the parameter matrices (each an \(N \times N\) SYMMETRIC matrix), initializes them and creates the HF FRML that describes the DVECH recursion. The \(\bf{A}\) parameters are all initialized to .05 and the \(\bf{B}\)'s to .80. (So highly persistent, but bounded away from 1). The \(\bf{C}\)'s are scaled to give an unconditional covariance that matches the observed RR covariance.
In the FRML HF instruction, .* is used for the elementwise product of two matrices.
dec symm vcs(n,n) vas(n,n) vbs(n,n)
compute vcs=rr*(1-.05-.80),vas=%const(0.05),vbs=%const(0.80)
nonlin(parmset=garchparms) vcs vas vbs
frml hf = vcs+vas.*uu{1}+vbs.*h{1}
nlpar(derives=second)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=10,$
iters=400) logl gstart gend
CC Model
For the CC model, the correlations are parameterized using an \((n-1)\times(n-1)\) matrix for the subdiagonal. The (i,j) element of this will actually be the correlation between i+1 and j. Each individual series has an element in VCV for the \(c\) in its univariate GARCH model, VAV for the \(a\) and VBV for the \(b\).
dec symm qc(n-1,n-1)
dec vect vcv(n) vav(n) vbv(n)
The HFCCCGARCH FUNCTION returns the full covariance matrix at TIME. It does this by computing the diagonal elements into HX(I,I) for each diagonal element, then uses the function %CORRTOCV to combine the subdiagonal correlation matrix with the VECTOR of variances to produce the complete covariance matrix.
function hfcccgarch time
type symm hfcccgarch
type integer time
do i=1,n
compute hx(i,i)=vcv(i)+$
vbv(i)*h(time-1)(i,i)+vav(i)*uu(time-1)(i,i)
end do i
compute hfcccgarch=%corrtocv(qc,%xdiag(hx))
end
This sets up the GARCHPARMS with the VCV, VAV and VBV VECTORS and the coded QC matrix. The univariate GARCH parameters are initialized to an \(a\) of .05, \(b\) of .80 and \(c\) which gives the unconditional variance. The QC (again, the subdiagonal) is initialized to zeros.
frml hf = hfcccgarch(t)
nonlin(parmset=garchparms) vcv vav vbv qc
compute vcv=%xdiag(rr*(1-.05-.80)),vav=%const(0.05),$
vbv=%const(0.80),qc=%const(0.0)
maximize(parmset=meanparms+garchparms,pmethod=simplex,piters=10) $
logl gstart gend
Copyright © 2025 Thomas A. Doan