push_cov2cor | R Documentation |
Calculate the correlation matrix from the covariance matrix.
push_cov2cor(covmat)
covmat |
A matrix of covariances. |
The function push_cov2cor()
calculates the correlation matrix from
the covariance matrix, in place, without copying the data in memory.
The function push_cov2cor()
accepts a pointer to the
covariance matrix, and it overwrites it with the correlation matrix.
The function push_cov2cor()
is written in RcppArmadillo
C++
so it's much faster than R
code.
Void (no return value - modifies the covariance matrix in place).
## Not run:
# Calculate a time series of returns
retp <- na.omit(rutils::etfenv$returns[, c("IEF", "VTI", "DBC")])
# Calculate the covariance matrix of returns
covmat <- cov(retp)
# Calculate the correlation matrix of returns
push_cov2cor(covmat)
all.equal(covmat, cor(retp))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.