Build data and AI skills | 50% off

Last chance! 50% off unlimited learning

Sale ends in


correlation (version 0.8.0)

cor_to_cov: 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

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab