Cor Matrix Estimation using Copula
Purpose
Using Max Likelihood estimate and Canonical Maximum Likelihood ( CML ) to get the correlation structure amongst assets CML 1. First estimate the marginals using the empirical distributions (without assumptions on the parametric form for each of them) 2. Estimate via MLE the copula parameters
temp.ret contains the returns of three assets
> head(temp.ret, 2)
GMT
Nifty100Ret GoldRet Liquid
2004-05-28 0.4835926 0.08272835 0.03473777
2004-05-31 0.4595340 0.06904175 0.03464168
> tail(temp.ret, 2)
GMT
Nifty100Ret GoldRet Liquid
2010-05-27 0.2201230 0.2832164 0.02502719
2010-05-28 0.2331315 0.2569849 0.02505284 |
Empirical Correlation and MCD Correlation Matrix are
> cor1 <- cov2cor(assetsMeanCov(workdata.ret, "cov")$cov)
> cor2 <- cov2cor(assetsMeanCov(workdata.ret, "MCD")$cov)
> cor1
Nifty100Ret GoldRet Liquid
Nifty100Ret 1.00000000 -0.02793342 -0.4740610
GoldRet -0.02793342 1.00000000 0.1073741
Liquid -0.47406102 0.10737413 1.0000000
> cor2
Nifty100Ret GoldRet Liquid
Nifty100Ret 1.00000000 -0.06133853 0.1920297
GoldRet -0.06133853 1.00000000 0.1484049
Liquid 0.19202966 0.14840486 1.0000000 |
Old Method
> gaus.cop <- ellipCopula(family = "normal", dim = 3, dispstr = "un",
+ param = c(0.1, 0.1, 0.1))
> loglik.marg <- function(b, x) {
+ return(sum(dnorm(x, b[1], b[2], log = T)))
+ }
> b1hat <- optim(c(0, 1), fn = loglik.marg, x = temp.ret[, 1],
+ control = list(fnscale = -1))$par
> b2hat <- optim(c(0, 1), fn = loglik.marg, x = temp.ret[, 2],
+ control = list(fnscale = -1))$par
> b3hat <- optim(c(0, 1), fn = loglik.marg, x = temp.ret[, 3],
+ control = list(fnscale = -1))$par
> udat <- cbind(pnorm(temp.ret[, 1], b1hat[1], b2hat[2]), pnorm(temp.ret[,
+ 2], b2hat[1], b2hat[2]), pnorm(temp.ret[, 3], b3hat[1], b3hat[2]))
> u <- udat
> a.o <- 0.5 * c(cor1[1, 2], cor1[1, 3], cor1[2, 3])
> fit <- fitCopula(gaus.cop, u, start = a.o, method = "ml") |
Comparison of results between the copula fit and rest are usual estimators
First is copula estimate, Second is simple cor estim and third is MCD based
> fit@estimate [1] -0.01537028 -0.24942721 0.11744008 > c(cor1[1, 2], cor1[1, 3], cor1[2, 3]) [1] -0.02793342 -0.47406102 0.10737413 > c(cor2[1, 2], cor2[1, 3], cor2[2, 3]) [1] -0.06133853 0.19202966 0.14840486 |
CML Method
> n <- dim(temp.ret)[1] > gaus.cop <- ellipCopula(family = "normal", dim = 3, dispstr = "un", + param = c(0.1, 0.1, 0.1)) > u <- (apply(temp.ret, 2, rank)/(n + 1)) > fit.ifl <- fitCopula(gaus.cop, u, start = c(0.2, 0.1, 0.1), method = "ml") |
Comparison of results between the CML based copula fit and the rest are usual estimator
First is copula estimate, Second is simple cor estim and third is MCD based
> fit.ifl@estimate [1] -0.030960314 -0.478677792 -0.001152047 > c(cor1[1, 2], cor1[1, 3], cor1[2, 3]) [1] -0.02793342 -0.47406102 0.10737413 > c(cor2[1, 2], cor2[1, 3], cor2[2, 3]) [1] -0.06133853 0.19202966 0.14840486 |