Page 1 of 1

Simulation study and Value at Risk

Posted: Tue Apr 07, 2009 2:07 am
by thomasft
Hi everybody,

Im working on a project about Value at Risk and need to do a monte carlo simulation of an AR(1)-GARCH(1,1) model.
I have estimated the AR(1) model with normal errors (I have the coeff etc) and need to simulate it over a 5 year period (daily observations - 252 pr year), outputting the simulated values in a new series so I can use the @quantile function to find the eg. 5% quantile (the VaR-estimat) of each day. I probably need to simulate the model with 1000 simulations pr. day.
Can anyone give me a hint as to where I should look? Have you tried to code something similar?

Thanks for your time,

Regards
Thomas

Re: Simulation study and Value at Risk

Posted: Tue Apr 07, 2009 9:14 am
by QSnakecharmer
To my knowledge, there's no way to do monte carlo simulations like the one you want to do in eviews right now (maybe someone can write a program for that).

What i usually do is to fit the model in eviews and then make a copy of it in excel (you just have to build the math structure of the AR-GARCH and then copy the estimators), and then i do the monte carlo simulation right there in excel with another program... but well, I’m just a freshman quant :wink:

Re: Simulation study and Value at Risk

Posted: Tue Apr 07, 2009 9:33 am
by EViews Gareth
I think you're over-stating the difficulty of doing this in EViews, somewhat. It shouldn't be that hard at all to do.

With a bit of digging around on my hard disk, I found an AR(2) Monte Carlo program I wrote a while back. It does a little more than you need, since it does some forecasting, and then records how good the forecasts are, but you should be able to get the gist of what is going on from it. All you'd need to do is change the error term specification from an AR(2) to an AR(1) GARCH(1,1).

Code: Select all

rndseed 1 'set seed for random number generator !M = 1000 ' number of experiments !N = 1000 ' historical period !H = 20 ' forecast period !NN = !n + !h 'total length of workfile !p1 = 0.6 'AR 1 term !p2 = 0.3 'AR 2 term !B0 = 100 'constant !B1 = 4 'coeffient for X1 !B2 = 1 'coefficient for X2 !k = 5 'number of coefficients + ar terms 'create workfile create u !nn 'declare objects to be used in simulations equation e1 matrix(!m,!k) Cmat 'matrix to store coefficient values over simulations matrix(!m,3) Dmat 'matrix to store last period forcast value and bools for above or below actual 'create x series series x1=nrnd series x2=nrnd 'run simulations for !sim=1 to !m 'create error term series u = nrnd smpl @first+2 @last series u = nrnd + !p1*u(-1) + !p2*u(-2) 'create y series series y = !b0 + !b1*x1 + !b2*x2 + u 'estimate equation smpl @first !n e1.ls y c x1 x2 ar(1) ar(2) 'store coefficient estimates rowplace(Cmat,@transpose(e1.@coefs),!sim) 'make forecast smpl !n+1 @last e1.forecast yf 'reset sample smpl @all 'grab last period forecast dmat(!sim,1)=( @elem(yf,@str(!nn)) - @elem(y,@str(!nn)) )^2 'set bools dmat(!sim,2) = @elem(yf,@str(!nn)) > @elem(y,@str(!nn)) dmat(!sim,3) = @elem(yf,@str(!nn)) < @elem(y,@str(!nn)) next vector dres = @cmean(dmat) vector cres = @cmean(cmat) show dres show cres