[R-SIG-Finance] [SPAM] - Monte Carlo simulation for VaR estimation - Email found in subject

Arun.stat arun.kumar.saha at gmail.com
Mon Nov 21 09:39:58 CET 2011


Hi Andrija, I am not sure why you need to replicate 10 times. Instead you
should want to replicate once with, say, 1000 simulation and then get the
5th percentile of the portfolio return distribution. Here you go:

l<-list("vector",1) 
mu<-apply(sh,2,mean) 
sigma<-cov(sh) 
#generate 1 replication
l<-list("vector",1) 
for (i in 1:1) 
{ 
l[[i]]<-rmnorm(1000,mu,sigma) # this will generate 1000 possible asset
returns based on the same statistical characteristic as in 'sh'
							  # I assume, 'sh' is your historical asset return
} 

l <- l[[1]]
pr_simulated <- apply(l, 1, function(x) return(sum(x * c(0.5, 0.5)))) #
simulated portfolio return
quantile(pr_simulated, 0.05, type = 3) # your Portfolio VaR (95%)

PS: I used rmnorm() function for drawing random number from a multivariate
normal, which is from 'mnormt' package.

HTH,

Thanks and regards,
_____________________________________________________

Arun Kumar Saha, FRM
QUANTITATIVE RISK AND HEDGE CONSULTING SPECIALIST
Visit me at: http://in.linkedin.com/in/ArunFRM
_____________________________________________________


--
View this message in context: http://r.789695.n4.nabble.com/Monte-Carlo-simulation-for-VaR-estimation-tp4082611p4090907.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list