开发者

log covariance to arithmetic covariance matrix function?

开发者 https://www.devze.com 2023-04-11 12:43 出处:网络
Is there a function that can convert a covariance matrix built using log-returns into a covariance matrix based on simple arithmetic returns?

Is there a function that can convert a covariance matrix built using log-returns into a covariance matrix based on simple arithmetic returns?

Motivation: We'd like to use a mean-variance utility function where expected returns and variance is specified in arithmetic terms. However, estimating returns and covariances is often performed with log-returns because of the additivity 开发者_如何学Cproperty of log returns, and we assume asset prices follow a lognormal stochastic process.

Meucci describes a process to generate a arithmetic-returns based covariance matrix for a generic/arbitrary distribution of lognormal returns on Appendix page 5.


Here's my translation of the formulae:

linreturn <- function(mu,Sigma) {
  m <- exp(mu+diag(Sigma)/2)-1
  x1 <- outer(mu,mu,"+")
  x2 <- outer(diag(Sigma),diag(Sigma),"+")/2
  S <- exp(x1+x2)*(exp(Sigma)-1)
  list(mean=m,vcov=S)
}

edit: fixed -1 issue based on comments.

Try an example:

m1 <- c(1,2)
S1 <- matrix(c(1,0.2,0.2,1),nrow=2)

Generate multivariate log-normal returns:

set.seed(1001)
r1 <- exp(MASS::mvrnorm(200000,mu=m1,Sigma=S1))-1
colMeans(r1)
## [1]  3.485976 11.214211
var(r1)
##         [,1]     [,2]
## [1,] 34.4021  12.4062
## [2,] 12.4062 263.7382

Compare with expected results from formulae:

linreturn(m1,S1)

## $mean
## [1]  3.481689 11.182494

## $vcov
##          [,1]      [,2]
## [1,] 34.51261  12.08818
## [2,] 12.08818 255.01563
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号