Description Usage Arguments Details Value Note Author(s) References Examples
The function ‘repairs’ an indefinite correlation matrix by replacing its negative eigenvalues by zero.
1 |
C |
a correlation matrix |
The function ‘repairs’ a correlation matrix: it replaces
negative eigenvalues with eps
and rescales the matrix such that
all elements on the main diagonal become unity again.
Returns a numeric matrix.
This function may help to cure a numerical problem, but it will rarely help to cure an empirical problem. (Garbage in, garbage out.)
See also the function nearPD
in the Matrix package.
Enrico Schumann
Gilli, M., Maringer, D. and Schumann, E. (2011) Numerical Methods and Optimization in Finance. Elsevier. http://www.elsevierdirect.com/product.jsp?isbn=9780123756626
Rebonato, R. and Jaeckel, P. (1999) The most general methodology to create a valid correlation matrix for risk management and option pricing purposes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## example: build a portfolio of three assets
C <- c(1,.9,.9,.9,1,.2,.9,.2,1)
dim(C) <- c(3L, 3L)
eigen(C, only.values = TRUE)
vols <- c(.3, .3, .3) ## volatilities
S <- C * outer(vols,vols) ## covariance matrix
w <- c(-1, 1, 1) ## a portfolio
w %*% S %*% w ## variance of portfolio is negative!
sqrt(as.complex(w %*% S %*% w))
S <- repairMatrix(C) * outer(vols,vols)
w %*% S %*% w ## more reasonable
sqrt(w %*% S %*% w)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.