Panel Garch: coding general mean and conditional varian

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

Re: Panel Garch: coding general mean and conditional varian

Unread post by TomDoan »

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?
These do the recursion:

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.
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?
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: 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?
Correct. The lag coefficients are common, but the variance intercepts aren't.
suhriz wrote: 4. Which one from Duma and theta will be the coefficient of our variable which we have introduced in variance equation?
What exactly are your DUMANN variables? They sound like they're dummies of some form. Are they different for different banks?
suhriz
Posts: 5
Joined: Thu Jun 13, 2013 2:29 am

Re: Panel Garch: coding general mean and conditional varian

Unread post by suhriz »

What exactly are your DUMANN variables? They sound like they're dummies of some form. Are they different for different banks?
Yes these are dummies and are different for different banks. although these are dummies in this case but i want to add real variables later in my paper. and those will be different for different banks.
for DUMANN (our variable in variance equation) we break it into diagonal and off-diagonal with duma and Theta... so which one we will interpret as coefficient of DUMANN? Diagonal (Duma) or off-Diagonal (Theta)? this is only confusion i am left with.

Also please tell me if this code is correct for estimation? because i am not giving weights for Duma and Theta and hence giving them zero value for likelihood.

Thank a lot Tom for replying. You are blessing for me as no one is here to help me for this. :-)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Panel Garch: coding general mean and conditional varian

Unread post by TomDoan »

This has less to do with getting the programming correct than it does with getting the effect of the dummies figured out. As you have it written (which won't work, but that's a secondary issue), each dummy has the same additive effect on the variance of each variable, and the same (but different value) effect on each covariance. Given that the model allows for a freely estimated "intercept" in the variance equation, forcing a common shift seems like a bad idea. How do you see a dummy in bank 1 affecting the variance in bank 1, and the covariance with bank 2? And if the timing on the dummies doesn't match, is there something different that needs to be done in the covariance for the period where one dummy is on and the other is off?
suhriz
Posts: 5
Joined: Thu Jun 13, 2013 2:29 am

Re: Panel Garch: coding general mean and conditional varian

Unread post by suhriz »

Ok sir let me explain you what i want to do so that we can come on same line...
Suppose there are 3 banks... A, B, C...
there is one variable 1 of each bank... means A1, B1 and C1
Now we used this in Mean equation with its lags etc...
Now in Variance equation: There is a variable 2 of every bank i.e. A2, B2 and C2.
We want to model variance equation of "1" variable in such a way that we can check effect of A2 on variance of A1, B2 on variance of B1 and C2 on variance of C1.
We are not interested in Covariances. Now what you will suggest?
Note: The variable "2" is not a dummy now.. this is a continuous variable having different value for different bank.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Panel Garch: coding general mean and conditional varian

Unread post by TomDoan »

suhriz wrote:Ok sir let me explain you what i want to do so that we can come on same line...
Suppose there are 3 banks... A, B, C...
there is one variable 1 of each bank... means A1, B1 and C1
Now we used this in Mean equation with its lags etc...
Now in Variance equation: There is a variable 2 of every bank i.e. A2, B2 and C2.
We want to model variance equation of "1" variable in such a way that we can check effect of A2 on variance of A1, B2 on variance of B1 and C2 on variance of C1.
We are not interested in Covariances. Now what you will suggest?
Note: The variable "2" is not a dummy now.. this is a continuous variable having different value for different bank.
I'm confused about why you think a panel GARCH model is the best base model for what you're doing. The panel GARCH is a very tightly parameterized variant on the DVEC GARCH model.
suhriz
Posts: 5
Joined: Thu Jun 13, 2013 2:29 am

Re: Panel Garch: coding general mean and conditional varian

Unread post by suhriz »

Tom wrote: I'm confused about why you think a panel GARCH model is the best base model for what you're doing. The panel GARCH is a very tightly parameterized variant on the DVEC GARCH model.
sir i want to write a code at the moment for this estimation. further testing will show the suitability of Panel GARCH for this purpose. Please do help me in this regard :(
Post Reply