RATS 10.1
RATS 10.1

Examples /

GARCHSEMIPARAM.RPF

Home Page

← Previous Next →

GARCHSEMIPARAM.RPF estimates a GARCH model by semi-parametric methods, which means that the GARCH lag model for the variance is estimated parametrically, but the underlying density of the standardized residuals is estimated non-parametrically (using the DENSITY instruction).

 

This estimates a standard GARCH(1,1) model, and extracts the standardized residuals. We want a non-parametric estimate for the density of those.

 

garch(p=1,q=1,hseries=h,resids=u) / xjpn

compute gstart=%regstart(),gend=%regend()

set ustandard gstart gend = u/sqrt(h)

 

This uses @GRIDSERIES to define a very fine grid over \(\left[ { - 8,8} \right]\). This uses X0 and XDELTA for the range and interval size which will be used later to interpolate the density.

 

compute x0=8.0,xdelta=.001
@gridseries(from=-x0,to=x0,size=xdelta,pts=gpts) xgrid
 

And DENSITY to compute the the empirical density of the standardized residuals over that grid:

 

density(type=gauss,grid=input) ustandard gstart gend xgrid fgrid

 

This does a graphical comparison of the empirical density with the standard Normal. (%DENSITY is the standard Normal density function).

 

set ngrid 1 gpts = %density(xgrid)

scatter(style=line,key=upleft,klabels=||"Empirical","N(0,1)"||) 2

# xgrid fgrid

# xgrid ngrid

 

To use the estimated density as an alternative to a Normal or t, we need to be able to compute a density value for any input positive value. Inside the range from DENSITY, it's simplest to do a linear interpolation, which is why a very fine grid was used. It's extended beyond the range with Gaussian-shaped tails. (The very wide empirical range should make the importance of that unlikely).

 

This defines a FUNCTION which returns the empirical log density given the GARCH variance and residual. This is in the correct form to be used for the DENSITY option on GARCH. What we've computed above is an empirical distribution for a standardized residual, so this needs to be standardized, and the log density adjusted for the variance at the end.

 

function gridvalue h u

type real gridvalue h u

local real stdu

compute stdu=u/sqrt(h)

if stdu<-x0

   compute density=fgrid(1)*exp(-(stdu+x0)^2)

else

if stdu>x0

   compute density=fgrid(gpts)*exp(-(stdu-x0)^2)

else {

   compute slot=(stdu+x0)/xdelta

   compute frac=slot-fix(slot)

   compute density=fgrid(fix(slot))*(1-frac)+fgrid(fix(slot)+1)*frac

}

compute gridvalue=-.5*log(h)+log(density)

end


With the work done above, the semi-parametric GARCH model can be estimated simply with a GARCH instruction with the DENSITY option to replace the standard densities:

 

garch(p=1,q=1,density=gridvalue,title="Semi-Parametric GARCH") / xjpn


Full Program

 

cal(d) 1973:1:1

open data g10xrate.xls

data(org=columns,format=xls) 1 1997:11:06 usxjpn

*

set xjpn = 100.0*log(usxjpn/usxjpn{1})

*

garch(p=1,q=1,hseries=h,resids=u) / xjpn

compute gstart=%regstart(),gend=%regend()

*

* Standardize the historical residuals

*

set ustandard gstart gend = u/sqrt(h)

*

* Define the empirical density over the range from -8 to 8 (standard

* errors).

*

compute x0=8.0,xdelta=.001

@gridseries(from=-x0,to=x0,size=xdelta,pts=gpts) xgrid

density(type=gauss,grid=input) ustandard gstart gend xgrid fgrid

set ngrid 1 gpts = %density(xgrid)

scatter(style=line,footer="Empirical Density",$

    key=upleft,klabels=||"Empirical","N(0,1)"||) 2

# xgrid fgrid

# xgrid ngrid

*********************************************************************

*

* Computes an linearly interpolated log density function for a GARCH

* (variance,residual) pair. This extends the tails beyond the [-x0,x0] range

* using Gaussian-shaped tails.

*

function gridvalue h u

type real gridvalue h u

local real stdu

compute stdu=u/sqrt(h)

if stdu<-x0

   compute density=fgrid(1)*exp(-(stdu+x0)^2)

else

if stdu>x0

   compute density=fgrid(gpts)*exp(-(stdu-x0)^2)

else {

   compute slot=(stdu+x0)/xdelta

   compute frac=slot-fix(slot)

   compute density=fgrid(fix(slot))*(1-frac)+fgrid(fix(slot)+1)*frac

}

compute gridvalue=-.5*log(h)+log(density)

end

*

* Do maximum likelihood using the empirical log likelihood.

* This used the DENSITY option on GARCH to replace the standard densities with the

* empirical one.

*

garch(p=1,q=1,density=gridvalue,title="Semi-Parametric GARCH") / xjpn

 

Output

 

GARCH Model - Estimation by BFGS

Convergence in    21 Iterations. Final criterion was  0.0000073 <=  0.0000100

 

Dependent Variable XJPN

Daily(5) Data From 1973:01:02 To 1996:11:26

Usable Observations                      6236

Log Likelihood                     -5395.4384

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Mean(XJPN)                   0.0001874859 0.0064882526      0.02890  0.97694737

2.  C                            0.0074286000 0.0011069606      6.71081  0.00000000

3.  A                            0.1762880839 0.0118295284     14.90238  0.00000000

4.  B                            0.8372689759 0.0095560842     87.61632  0.00000000

 

 

Semi-Parametric GARCH - Estimation by BFGS

Convergence in    48 Iterations. Final criterion was  0.0000064 <=  0.0000100

 

Dependent Variable XJPN

Daily(5) Data From 1973:01:02 To 1996:11:26

Usable Observations                      6236

Log Likelihood                     -4825.2887

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Mean(XJPN)                   -0.001467667  0.003642868     -0.40289  0.68703083

2.  C                             0.006193670  0.000205294     30.16973  0.00000000

3.  A                             0.189718170  0.004736429     40.05511  0.00000000

4.  B                             0.835444595  0.002690476    310.51930  0.00000000

 

 

Graph

 


Copyright © 2025 Thomas A. Doan