* * Example from section 10.7 from pp 481-482 * open data d-spcscointc.txt data(format=free,org=columns) 1 2275 sp500 cisco intel * * Create the two mean equations, and group them into a model * equation eq1 cisco # constant cisco{1 2 3} equation eq2 intel # constant group bimodel eq1 eq2 * * Do the univariate GARCH models and forecast the variances. (You need to do the * variance forecasts immediately after the GARCH instruction) * garch(equation=eq1,p=1,q=1,resids=a1,hseries=h1) @garchfore(steps=1) h1 a1 garch(equation=eq2,p=1,q=1,resids=a2,hseries=h2) @garchfore(steps=1) h2 a2 * * Forecast the means * forecast(model=bimodel,steps=1,results=rhat) compute q1=rhat(1)(2276)+%invnormal(.05)*sqrt(h1(2276)) compute q2=rhat(2)(2276)+%invnormal(.05)*sqrt(h2(2276)) vcv(noprint) # a1 a2 compute rho=%sigma(1,2)/sqrt(%sigma(1,1)*%sigma(2,2)) compute q12=sqrt(q1**2+q2**2+2*rho*q1*q2) * disp "Univariate Models" disp "VaR on Cisco" @20 -10000*q1 disp "VaR on Intel" @20 -10000*q2 disp "VaR Overall" @20 10000*q12 * garch(model=bimodel,p=1,q=1,mv=cc,hmatrices=h,rvectors=a) * @mvgarchfore(steps=1,mv=cc) h a forecast(model=bimodel,steps=1,results=rhat) * compute q1=rhat(1)(2276)+%invnormal(.05)*sqrt(h(2276)(1,1)) compute q2=rhat(2)(2276)+%invnormal(.05)*sqrt(h(2276)(2,2)) compute rho=h(2276)(1,2)/sqrt(h(2276)(1,1)*h(2276)(2,2)) compute q12=sqrt(q1**2+q2**2+2*rho*q1*q2) disp "Bivariate Model" disp "VaR on Cisco" @20 -10000*q1 disp "VaR on Intel" @20 -10000*q2 disp "VaR Overall" @20 10000*q12