[R-SIG-Finance] Risk management research simulation questions
Krishna Kumar
kriskumar at earthlink.net
Wed Aug 30 02:53:22 CEST 2006
A small typo
hist.var <- qnorm(0.05,mean=hist.vol,sd=hist.vol)
should read
hist.var <- qnorm(0.05,mean=hist.mean,sd=hist.vol)
Krishna Kumar wrote:
> 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:
>
>> I should have been a little more specific. I need help simulating
>> the correlated assets.
>> thanx
>>
>>
>> Joe Byers wrote:
>>
>>
>>> Rmetrics group,
>>>
>>> I am working on a project to determine the errors associated with
>>> structural assumptions underlying a companies Value at Risk
>>> calculation. Normal VAR calculations using a covariance matrix for
>>> the portfolio assume constant mean or zero mean if the returns are
>>> mean adjusted. This project calls for creating 4-5 hypothetical
>>> assets, 1 constant mean and variance, 1 seasonal mean and constant
>>> variance, 1 constant mean and seasonal variance, 1 time varying mean
>>> (AR or Garch in mean), 1 time varying variance (GARCH type). I want
>>> to provide the hypothetical parameters for these assets and simulate
>>> returns. I can simulate each of these assets as independent but
>>> really need correlated errors.
>>>
>>> These returns will be used to calculate a benchmark risk metrics
>>> type VAR and then progess through correcting the VAR calculations
>>> for each case of asses type.
>>>
>>> Anyone that is interested, I would appreciate suggestions. I am
>>> also favoring co-authorship for this help.
>>>
>>> Thank you
>>> Joe
>>>
>>>
>>
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>
>>
>>
>
>
More information about the R-SIG-Finance
mailing list