cor_to_cov {correlation}R Documentation

Convert a correlation to covariance

Description

Convert a correlation to covariance

Usage

cor_to_cov(cor, sd = NULL, variance = NULL, tol = .Machine$double.eps^(2/3))

Arguments

cor

A correlation matrix, or a partial or a semipartial correlation matrix.

sd, variance

A vector that contains the standard deviations, or the variance, of the variables in the correlation matrix.

tol

Relative tolerance to detect zero singular values.

Value

A covariance matrix.

Examples

cor <- cor(iris[1:4])
cov(iris[1:4])

cor_to_cov(cor, sd = sapply(iris[1:4], sd))
cor_to_cov(cor, variance = sapply(iris[1:4], var))

[Package correlation version 0.8.4 Index]