| cor2cov | R Documentation |
Converts a correlation matrix into a covariance matrix using variance information. It is therefore the inverse of cov2cor.
cor2cov(C, var = NULL)
C |
a symmetric numeric correlation matrix |
var |
a vector of variances |
Calculates the covariance matrix \mathbf{\Sigma} from a correlation matrix \mathbf{C} and the outer product of the vector of standard deviations \mathbf{s} = (s_1, \ldots, s_N)^T, with s_i^2 the elements of var, by the elementwise (Hadamard) product \circ:
\mathbf{\Sigma} = \mathbf{s}\mathbf{s}^T \circ \mathbf{C}, \qquad \Sigma_{ij} = s_i\, s_j\, C_{ij}
This is equivalent to \mathbf{\Sigma} = \mathbf{D}\mathbf{C}\mathbf{D} with \mathbf{D} = \mathrm{diag}(\mathbf{s}), the inverse of the relation r(x_i, x_j) = u(x_i, x_j)/(u(x_i)\, u(x_j)) of JCGM 100:2008, 5.2.2.
The corresponding covariance matrix.
Andrej-Nikolai Spiess
Evaluation of measurement data - Guide to the expression of uncertainty in measurement.
JCGM 100:2008. Joint Committee for Guides in Metrology (2008).
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.59161/JCGM100-2008E")}
## JCGM 100:2008, Annex H.2
## (see 'References'), simultaneous resistance
## and reactance measurement.
data(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.