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
Risk management research simulation questions
9 messages · Joe Byers, Brian G. Peterson, gyadav at ccilindia.co.in +1 more
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
On Monday 28 August 2006 10:40, 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.
I've had very good success using Modified Cornish-Fisher VaR to handle the non-normality of the distribution, occasionally with a weighted average of since-inception VaR and rolling period VaR. Why wouldn't you choose existing (real) assets with the characteristics that you want to use in your simulated portfolios? If you want to simulate assets, there are several simulation functions in RMetrics and in other R packages, and I'd suggest that you start there. However, I don't find that these end up looking much like the distributions of real assets in practice, so I don't tend to use them very often. Regards, - Brian
I want to simulate hypothetical assets so I can control all aspects of the tests, from parameters to correlations across assets. I can construct correlations based on minimum variance hedge ratios that will allow me to create hedge portfolios with higher weights on some assets than others. This way I can also look at hedging aspects within the VAR calculation and the problems with violating the models assumptions. I have used garchsim and armasim, but as I understand their implementation, I am simulating the independent process, not a correlated process. Including the modified cornish VAR is a really good idea as a benchmark case as well. thanks for that suggestion, if nothing else you are entitled to a footnote for it. Thanx Joe
Brian G. Peterson wrote:
On Monday 28 August 2006 10:40, 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.
I've had very good success using Modified Cornish-Fisher VaR to handle the non-normality of the distribution, occasionally with a weighted average of since-inception VaR and rolling period VaR. Why wouldn't you choose existing (real) assets with the characteristics that you want to use in your simulated portfolios? If you want to simulate assets, there are several simulation functions in RMetrics and in other R packages, and I'd suggest that you start there. However, I don't find that these end up looking much like the distributions of real assets in practice, so I don't tend to use them very often. Regards, - Brian
-------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20060828/800933a3/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: joe-byers.vcf Type: text/x-vcard Size: 295 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20060828/800933a3/attachment.vcf
1 day later
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
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
Krishna, Thank you for the very useful simulation code. I would like to correct an oversimplification on your estimate of VaR.
On Tuesday 29 August 2006 19:50, Krishna Kumar wrote:
#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))
This isn't always correct for non-normal distributions. See my earlier posts on Modified Cornish-Fisher VaR here: ? ? http://article.gmane.org/gmane.comp.lang.r.r-metrics/855 A function to calculate modified Cornish-Fisher VaR for all distributions and a variety of other R functions for dealing with higher moments of the return distribution may be found here: http://braverock.com/brian/R/extra_moments.R I suspect that you might be able to use quantile if you understood enough about the distribution to know which estimating technique to use, but it will be more accurate to calculate the moments directly, using the modifiedVaR function in the file I link to above. Regards, - Brian
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20060831/dbeb191a/attachment.pl
Yep that is correct.
hist.mean <- ret.mean %*% wts
Hope this helps
Sent from my BlackBerry? wireless handheld
-----Original Message-----
From: gyadav at ccilindia.co.in
Date: Thu, 31 Aug 2006 17:43:53
Cc:r-sig-finance at stat.math.ethz.ch, r-sig-finance-bounces at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] Risk management research simulation questions
hi Krishna
I feel that there is one more typo error in your code. Please clarify me
if in case i am wrong....
hist.mean <- sum(ret.mean,wts)
should be multiplication of weights as mean = mu1*wt1 + mu2*wt2 + mu3*wt3
thanks
Sayonara With Smile & With Warm Regards :-)
G a u r a v Y a d a v
Senior Executive Officer,
Economic Research & Surveillance Department,
Clearing Corporation Of India Limited.
Address: 5th, 6th, 7th Floor, Trade Wing 'C', Kamala City, S.B. Marg,
Mumbai - 400 013
Telephone(Office): - +91 022 6663 9398 , Mobile(Personal) (0)9821286118
Email(Office) :- gyadav at ccilindia.co.in , Email(Personal) :-
emailtogauravyadav at gmail.com
============================================================================================
DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}}
_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance