Thank you in advance
your help was very usefull in the last two moths and has helped me a lot since i am a new user in Rats
Maria
The code:
Code: Select all
open data kor.xls
data(format=xls,org=columns) 1 284 lmr fxr mmr
*
*
* Estimation using MAXIMIZE
* 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 residuals formulas are set up. The SET instructions
* copy the dependent variables over into the slots in the vector of series.
*
compute gstart=2,gend=284
compute n=3
dec vect[series] y(n) u(n)
dec vect[frml] resid(n)
set y(1) = lmr
set y(2) = fxr
set y(3) = mmr
*
* 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) o(n) w(n) k(n)
nonlin(parmset=meanparms) b o(1) o(2) w(1) w(2) k
frml lmreq lmr = b(1) + o(1)*lmr{1} + w(1)*fxr{1} + k(1)*mmr{1} + u(1)
frml fxreq fxr = b(2) + o(2)*lmr{1} + w(2)*fxr{1} + k(2)*mmr{1} + u(2)
frml mmreq mmr= b(3) + k(3)*mmr{1} + u(3)
frml resid(1) = (lmr-b(1)-o(1)*lmr{1}-w(1)*fxr{1}-k(1)*mmr{1})
frml resid(2) = (fxr-b(2)-o(2)*lmr{1}-w(2)*fxr{1}-k(2)*mmr{1})
frml resid(3) = (mmr-b(3)-k(3)*mmr{1})
* the third equation is an AR(1) BUT the first two a VAR(1)
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] names
* H and UU. UX and HX are used to pull in residuals and H matrices.
*
declare series[symm] h uu
*
* ux is used when extracting a u vector
*
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)
*****************************************************
*
* Positive definite parameterization (BEKK,EK)
* This enforces a positive definite covariance matrix by writing the covariance
* matrix evolution as
*
* V(t) = C'C + A'u(t)u(t)'A + B'V(t-1)B
*
* Note that the parameters are not globally identified: changing the signs of all
* members of C, A or B will have no effect on the function value. Using
* PMETHOD=SIMPLEX to begin is quite important with this setup, to pull the
* estimates away from zero before starting the derivative-based methods.
*
dec rect var(n,n) vbr(n,n)
dec packed vcr(n,n)
nonlin(parmset=garchparms) vcr var vbr
nonlin(parmset=restrictions) var(3,1)=var(3,2)=0.0 vbr(3,1)=vbr(3,2)=0.0
frml hf = $
hx=h{1},uux=uu{1},$
%ltouterxx(vcr)+%mqform(uux,var)+%mqform(hx,vbr)
*
* Initialize c's from the decomp of the covariance matrix
*
compute vcr = %decomp(rr)
compute var = %mscalar(.05) , vbr = %mscalar(.05)
*
maximize(parmset=meanparms+garchparms+restrictions,pmethod=simplex,piters=100,method=bfgs,robust,iters=1500) logl gstart gend