Re: Panel Garch: coding general mean and conditional varian
Posted: Thu Jun 20, 2013 11:27 am
These do the recursion:suhriz wrote:Dear Tom,
let me first show you code i have generalized for 4 firms from 3. code with 3 were given on link you mentioned here (thanks for that).
I edited the code for 4 firms. and also entered the Xit variable in variance equation.
Have a look at it:------------------------------------------------------------------------------------------------Code: Select all
OPEN DATA "C:\Users\SuhRiz\Desktop\short sale.xls" DATA(FORMAT=XLS,ORG=COLUMNS) 1 944 abank bbank cbank dbank dabank dbbank dcbank ddbank * 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=5,gend=900 ;* set the estimation range compute n=4 ;*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # variables dec vect[series] y(n) u(n) yL1(n) dumann(n) dec vect[frml] resid(n) set y(1) = abank set y(2) = bbank set y(3) = cbank set y(4) = dbank set yL1(1) = abank{1} set yL1(2) = bbank{1} set yL1(3) = cbank{1} set yL1(4) = dbank{1} set dumann(1) = dabank set dumann(2) = dbbank set dumann(3) = dcbank *these 4 are variable vector which we want to introduce in variance equation set dumann(4) = ddbank * * 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) * Now do it in a loop to see if identical to above nonlin(parmset=meanparms) b ar do i=1,n frml resid(i) = (y(&i)-b(&i)-ar(&i)*yL1(&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) vds(n,n) dec real delta lambda gamma rho duma theta dec symm vbs(n,n) vas(n,n) vdann(n,n) * compute vcs=rr*.1,delta=lambda=.8,gamma=rho=.1 compute vds=%zeros(n,n) nonlin(parmset=garchparms) vcs delta lambda gamma rho duma theta frml hf = vcs+vds*dumann(&i)+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) ewise vds(i,j)=%if(i==j,duma,theta) end * maximize(start=PGARCHInit(),parmset=meanparms+garchparms,pmethod=simplex,piters=10,method=bfgs,iters=400) logl gstart gend
Now my confusions are:
1. Which one from Delta and Lambda is coefficient of lag variance term?
frml hf = vcs+vds*dumann(&i)+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)
ewise vds(i,j)=%if(i==j,duma,theta)
end
So <<delta>> is on the diagonals of the B matrix and <<lambda>> is on the off-diagonals of B. B applies to the lagged (co)variances. Similarly <<gamma>> and <<rho>> determine the treatment of the lagged outer product of the residuals.
Yes. Those are the guess values. The .1 is (1-.8-.1) so the constant matrix VCS is set to return the RR matrix as the unconditional variance of the process. Probably zero is the best guess.suhriz wrote: 2. compute vcs=rr*.1,delta=lambda=.8,gamma=rho=.1-----in this compute command what these initial values are? Are these initial values for maximum likelihood? And should we give these values to our variables’s “Duma and Theta in this case” coefficients? If yes then what values we should give?
Correct. The lag coefficients are common, but the variance intercepts aren't.suhriz wrote: 3. VCS are the intercepts? Am I right? And we are not pooling it so that we can have different intercept for different company? Am I right sir?
What exactly are your DUMANN variables? They sound like they're dummies of some form. Are they different for different banks?suhriz wrote: 4. Which one from Duma and theta will be the coefficient of our variable which we have introduced in variance equation?