Skip to content
Prev 1020 / 15274 Next

Risk management research simulation questions

Hello Joe, Here is a simple piece of code that simulates correlated 
assets and computes both historical and MC VaR.

 Now for the seasonal mean and covariance a very inelegant way is to 
simply timestep the simulation and then generate random returns using 
the seasonal covariance(mean) I am not sure about using Garch and if 
indeed using pearson correlation one can generate Garch processes that 
have the required correlation structure. Essentially the marginal and 
joint distributions are unlikely to be gaussian and so ordinary 
correlation mayn't be a good measure of the dependence.
However I suggest a more practical alternative assuming marginal 
distribution one can easily use copula functions to generate very 
realistic scenarios.
This works very well and I like this approach better.

Indeed there appears to be a copula Garch model, there is a very nice 
copula library in R and univariate and multivariate Garch can be done
so one can attempt to do what these authors indicate 
(http://www.faculty.ucr.edu/~taelee/paper/LeeLong.pdf  and 
http://www.fame.ch/library/EN/RP69.pdf)
I haven't tried this yet.

Hope this helps,

Best,
Krishna



# the below code assumes 1 year VaR at the 95% level you'd have to scale 
volatility/returns if you want some other horizon!.

require(VaR)
data(DJIA)
require(MASS)
nsim<-1000
ticker<-c("INTC","IBM","GE")
mydata<-as.matrix(subset(DJIA,select=ticker))
retdata<-diff(log(mydata))
cov.mat<-cov(retdata)
wts<-c(0.2,0.4,0.4) # define your portfolio weights.
hist.vol<- sqrt(wts %*% cov.mat %*% wts)
ret.mean<-apply(retdata,2,mean)
hist.mean<-sum(ret.mean,wts)
#Historical VaR estimate
hist.var <- qnorm(0.05,mean=hist.vol,sd=hist.vol)
cat("historical VaR at the 95% level \n ", format(hist.var,digits=2))
sim.ret<-mvrnorm(nsim,mu=ret.mean,Sigma=cov.mat)
sim.wtret<-t(wts * t(sim.ret))
x11()
hist(sim.wtret)
#read the VaR as the quantile of the loss distribution
mc.var<-quantile(sim.wtret,0.05)
cat("mc VaR at the 95% level \n ", format(mc.var,digits=2))
Joe Byers wrote: