*
* GARCHBOOT.RPF
* Example of bootstrapping a GARCH model (for out-of-sample simulation
* of returns).
*
* RATS User's Guide, Example from Section 16.10.
*
all 6237
open data g10xrate.xls
data(format=xls,org=columns) / usxjpn
*
* Convert to percent daily returns
*
set x = 100.0*log(usxjpn/usxjpn{1})
*
* Estimate the GARCH(1,1) model.
*
garch(p=1,q=1,resids=u,hseries=h) / x
*
* Generate a forecasting formula from the results of the GARCH
* estimation. gstart and gend are the regression range, which we need
* for drawing standardized residuals.
*
compute gstart=%regstart(),gend=%regend()
compute b0=%beta(1),chat=%beta(2),ahat=%beta(3),bhat=%beta(4)
frml hf = chat+bhat*h{1}+ahat*u{1}^2
*
* Standardize the historical residuals
*
set ustandard gstart gend = u/sqrt(h)
*
* span is the number of periods over which returns are to be computed.
* ndraws is the number of bootstrapping draws
*
compute span=10
compute ndraws=10000
*
* Extend out the h series (values aren't important--this is just to get
* the extra space).
*
set h gend+1 gend+span = h(gend)
*
dec vect returns(ndraws)
do draw=1,ndraws
*
* This draws standardized u's from the ustandard series
*
boot entries gend+1 gend+span gstart gend
*
* Simulate the GARCH model out of sample, scaling up the standardized
* residuals by the square root of the current h.
*
set udraw gend+1 gend+span = ustandard(entries)
set u gend+1 gend+span = (h(t)=hf(t)),udraw(t)*sqrt(h(t))
*
* Figure out the cumulative return over the span. As written, this
* allows for the continuation of the sample mean return. If you want
* to look at zero mean returns, take the b0 out.
*
sstats gend+1 gend+span b0+u>>returns(draw)
end do draw
*
* Compute desired fractiles of the returns
*
compute [vect] pvals=||.01,.05,.10||
compute [vect] VaR=%fractiles(returns,pvals)
report(action=define,hlabels=||"P","VaR/$100"||)
do i=1,3
report(atrow=i,atcol=1) pvals(i) VaR(i)
end do i
report(action=show)