Code: Select all
all 500
compute n=2
*
* u is the simulated GARCH process
*
dec vect[series] u(n)
*
* H is the series of variance matrices, UU is the series of lagged outer products of the residuals.
*
dec series[symm] h uu
dec symm vc(n,n) va(n,n) vb(n,n)
compute vc=||.05|.01,.05||
compute va=||.90|.85,.90||
compute vb=||.05|.05,.05||
*
* Compute the stationary variance
*
dec symm h0(n,n)
ewise h0(i,j)=vc(i,j)/(1-va(i,j)-vb(i,j))
*
dec frml[symm] hf hu
dec symm hx
dec vect ux
*
frml hf = vc+va.*h{1}+vb.*uu{1}
frml hu = hx=hf,ux=%ranmvnormal(%decomp(hx)),uu=%outerxx(ux),%pt(u,t,ux),hx
*
* Initialize the UU and H series for the pre-sample values
*
gset uu = h0
gset h = h0
*
* Generate starting in entry 2.
*
gset h 2 500 = hu(t)
*
* Graph the series and variance series
*
graph(footer="First simulated series")
# u(1)
graph(footer="Second simulated series")
# u(2)
set h11 = h(t)(1,1)
graph(footer="Simulated variance for first series")
# h11