push_cov2cor: Calculate the correlation matrix from the covariance matrix.

View source: R/RcppExports.R

push_cov2corR Documentation

Calculate the correlation matrix from the covariance matrix.

Description

Calculate the correlation matrix from the covariance matrix.

Usage

push_cov2cor(covmat)

Arguments

covmat

A matrix of covariances.

Details

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.

Value

Void (no return value - modifies the covariance matrix in place).

Examples

## 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)


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.