Extracting correlations from a covariance matrix

Share:

Description

Extracting correlations from a covariance matrix

Usage

1

Arguments

mat

A covariance matrix.

Value

The correlation matrix embedded in mat.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 2 dimensional case
d <- 2
tmp <- matrix(rnorm(d^2), d, d)
mcov <- tcrossprod(tmp, tmp)

# Covariance matrix
mcov

# Correlation matrix
extractCorr(mcov)