Tuesday, July 17, 2018

correlation - Simulating Returns


I'll start this off with a rather broad question: I am trying to simulate returns of a large number of assets within a portfolio of different classes - equity and fixed income in a first step, say 100 stocks and 100 bonds. The main target is to preserve something similar to a realistic correlation structure within the returns. What would be a good way to go about it?


My first idea was to estimate the correlation between the classes, draw multivariate normal returns (yes, I know, but if you have better ideas, I'd like to hear them) based on historical mean, sd and correlation, and then replicate the two baseline return series with random errors, say something like (pseudo R code, I think it's clear what I mean)


require(mnormt)
n <- 100 # number of assets
m <- 1000 # days of simulated data
means <- apply(cbind(equity,bond),2,mean)
Sigma <- cov(cbind(equity,bond))
sim.returns <- rmnorm(1000,means,Sigma)

sim.equities <- matrix(sim.returns[,"equity"]*rnorm(m*n,mean=1,sd=0.5),ncol=n)
sim.bonds <- matrix(sim.returns[,"bond"]*rnorm(m*n,mean=1,sd=0.2),ncol=n)

Any suggestions, improvements or other comments wellcome - how would you do it, or do it better?


Update: This is were I am now (as of 2011-04-29):


require(quantmod)
rets.dax <- dailyReturn(GDAXI)
(DBCNumber <- 100)
(DBCNames <- as.character(paste("DBC",1:DBCNumber,sep="_")))
(DBCBetas <- runif(DBCNumber, min=0.8,max=1.5)) # seeding Betas

DBCErrors <- matrix(rnorm(nrow(rets.dax)*DBCNumber,sd=0.01),ncol=DBCNumber) #seeding errors
DBCReturns <- matrix(rep(NA,nrow(rets.dax)*DBCNumber),ncol=DBCNumber)
#simulating returns with the betas and errors
for(i in 1:DBCNumber){DBCReturns[,i] <- rets.dax*DBCBetas[i]+DBCErrors[,i]}
DBCReturns <- xts(DBCReturns,order.by=index(rets.dax))
colnames(DBCReturns) <- DBCNames
DBCIndizes <- xts(apply(DBCReturns+1,2,cumprod),order.by=index(rets.dax)) #calculating prices

cols <- heat.colors(DBCNumber)
chart.RelativePerformance(DBCReturns,rets.dax,colorset=cols, lwd=1)


I am quite happy now with the equity returns, but do you have suggestions for bond returns (data sources, can I copy the approach from equities?)




No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...