Learn R Programming

propagate (version 1.0-6)

cor2cov: Converting a correlation matrix into a covariance matrix

Description

Converts a correlation matrix into a covariance matrix using variance information. It is therefore the opposite of cov2cor.

Usage

cor2cov(C, var)

Arguments

C

a symmetric numeric correlation matrix \(\mathbf{C}\).

var

a vector of variances \(\sigma_n^2\).

Value

The corresponding covariance matrix.

Details

Calculates the covariance matrix \(\mathbf{\Sigma}\) using a correlation matrix \(\mathbf{C}\) and outer products of the standard deviations \(\sigma_n\): $$\mathbf{\Sigma} = \mathbf{C} \cdot \sigma_n \otimes \sigma_n$$

Examples

Run this code
# NOT RUN {
## Example in Annex H.2 from the GUM 2008 manual
## (see 'References'), simultaneous resistance
## and reactance measurement.
data(H.2)
attach(H.2)

## Original covariance matrix.
COV <- cov(H.2)
## extract variances
VAR <- diag(COV)

## cor2cov covariance matrix.
COV2 <- cor2cov(cor(H.2), VAR) 

## Equal to original covariance matrix.
all.equal(COV2, COV)
# }

Run the code above in your browser using DataLab