I NOW WISH TO ADD THE DUMMY VARIABLE TO THE VARIANCE EQU TO GET ITS OVERALL EFFECT ON THE CONDITIONAL VARIANCE OF THE PANEL. ALSO MAY WISH TO ADD FURTHER LAGGED VALUES OF UU TO THE CONDITIONAL VARIANCE. I ATTACH THE PRG BELOW. THANK YOU IN ADVANCE.
Code: Select all
all 6237
open data g10xrate.xls
data(format=xls,org=columns) / usxjpn usxfra usxsui
*Bring in dummy, say E.G. at obs 3000. Note that this is an identical dummy applied to each i in the panel
dummy(ao=3000) dumann1 /
dummy(ao=3000) dumann2 /
dummy(ao=3000) dumann3 /
*print / dumann1
*
set xjpn = 100.0*log(usxjpn/usxjpn{1})
set xfra = 100.0*log(usxfra/usxfra{1})
set xsui = 100.0*log(usxsui/usxsui{1})
*
* 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=3,gend=6237
compute n=3
dec vect[series] y(n) u(n) yl1(n) dumann(n)
dec vect[frml] resid(n)
set y(1) = xjpn
set y(2) = xfra
set y(3) = xsui
set yl1(1) = xjpn{1}
set yl1(2) = xfra{1}
set yl1(3) = xsui{1}
set dumann(1) = dumann1
set dumann(2) = dumann2
set dumann(3) = dumann3
*
* 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) ar(n) d(n)
* Do it first with separate frms's
*nonlin(parmset=meanparms) b1 b2 b3 ar1 ar2 ar3 d1 d2 d3
*frml resid(1) = y(1)-b1-ar1*yl1(1)-d1*dumann(1)
*frml resid(2) = y(2)-b2-ar2*yl1(2)-d2*dumann(2)
*frml resid(3) = y(3)-b3-ar3*yl1(3)-d3*dumann(3)
* Now do it in a loop to see if identical to above
nonlin(parmset=meanparms) b ar d
do i=1,n
frml resid(i) = (y(&i)-b(&i)-ar(&i)*yl1(&i)-d(&i)*dumann(&i))
end do i
nlsystem(parmset=meanparms,resids=u) gstart gend resid
compute rr=%sigma
display rr
*
* 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)
*****************************************************
*
* Panel GARCH - DVECH with restrictions. WISH TO ADD THE DUMMY VARIABLE ABOVE TO THE VARIANCE EQU TO GET ITS OVERALL EFFECT ON THE CONDITIONAL VARIANCE OF **THE PANEL. ALSO MAY WISH TO ADD FURTHER LAGGED VALUES OF UU
dec symm vcs(n,n)
dec real delta lambda gamma rho duma
dec symm vbs(n,n) vas(n,n) vdann(n,n)
*
compute vcs=rr*.1,delta=lambda=.8,gamma=rho=.1
nonlin(parmset=garchparms) vcs delta lambda gamma rho
frml hf = vcs+vbs.*h{1}+vas.*uu{1}
*
* Call once during START option to fill in the VAS and VBS arrays
*
function PGARCHInit
local integer i j
ewise vbs(i,j)=%if(i==j,delta,lambda)
ewise vas(i,j)=%if(i==j,gamma,rho)
end
*
maximize(start=PGARCHInit(),parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs,iters=400) logl gstart gend