* * GARCHSEMIPARAM.RPF * Semi-Parametric estimation of univariate GARCH model * Partially described in RATS Version 9 User's Guide, section 13.1 * 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}) stats xjpn compute samplevar=%variance * 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) @gridseries(from=-6.0,to=6.0,size=.001,pts=gpts) xgrid density(type=gauss,grid=input) ustandard gstart gend xgrid fgrid set ngrid 1 gpts = %density(xgrid) scatter(style=line,key=upleft,klabels=||"Empirical","N(0,1)"||) 2 # xgrid fgrid # xgrid ngrid ********************************************************************* * * Computes an interpolated standardized log density function. This * extends the tails beyond the [-6,6] range using the relative Normal * densities. * function gridvalue u type real gridvalue u if u<-6.0 compute density=fgrid(1)*exp(-(u+6.0)^2) else if u>6.0 compute density=fgrid(gpts)*exp(-(u-6.0)^2) else { compute slot=(u+6.0)*1000 compute frac=slot-fix(slot) compute density=fgrid(fix(slot))*(1-frac)+fgrid(fix(slot)+1)*frac } compute gridvalue=log(density) end * * Do maximum likelihood using the empirical log likelihood. While this * will properly estimate the parameter, note that the log likelihood * isn't comparable with the Normal log likelihood because the * integrating constant isn't known. * set uu = samplevar set h = samplevar nonlin(parmset=meanparms) b0 frml resid = xjpn-b0 nonlin(parmset=garchparms) vc va vb frml hf = vc + va*uu{1} + vb*h{1} compute b0=%beta(1),vc=%beta(2),va=%beta(3),vb=%beta(4) frml logl = (h=%ovcheck(hf)),u=resid,uu=u^2,-.5*log(h)+gridvalue(u/sqrt(h)) maximize(parmset=meanparms+garchparms,method=bfgs,robusterrors) logl gstart gend