Kevin im having a hard time getting this code to work (getting a strange number). Was there a typo somewhere?This result is way off. You can see this intuitively as weighted component vol is .229.
For large baskets, as n -> inf, implied corr will converge on basket-vol / weighted-component-vol. This overstates corr for small baskets. Rule of thumb iv**3 / crossprod(w**3,v**3) yields a guess of .77/
Explicitly calculating it corr comes in around .75:
rho = (iv**2 - crossprod(w**2,v**2) / sum(outer(v,v) * outer(w,w) - eye(3) * diag(outer(v,v) * outer(w,w)))
I re-did this example with a 100 asset portfolio. I realized that if I take the square root of the output from the original formula I get the same output as iv/sum(v*w). Is that because we calculated in vars?
Here is the R code if you want to give it a run (should be 0 errors).
Code:
#create weights and vol vectors for a 100 asset portfolio
x<-runif(100)
w = x/sum(x)
v = rnorm(100, mean = .35, sd = .07)
vIndex = .21
#create vector and matrix for top and bottom summations
top.sum = vector()
bottom.sum = matrix(nrow = length(v), ncol = length(v))
#loop over inputs
for(i in 1:length(v)){
top.sum[i] = w[i]^2 * v[i]^2
for(j in 1:length(v)){
bottom.sum[i,j] = w[i]*w[j]*v[i]*v[j]
}
}
#get the upper right corner of our matrix
mat = bottom.sum[upper.tri(bottom.sum)]
#print implied correlation
ic = (vIndex^2 - sum(top.sum))/(2 * sum(mat))
#print difference between 2 formulas
vIndex/sum(v*w) - sqrt(ic)
there is very little difference
