sdpcor2cov: sdcor2cov

Description Usage Arguments Examples

View source: R/sdpcor2cov.R

Description

Converts a lower triangular matrix with standard deviations on the diagonal and partial correlations on lower triangle, to a covariance (or cholesky decomposed covariance)

Usage

1
sdpcor2cov(mat, cholesky = FALSE)

Arguments

mat

input square matrix with std dev on diagonal and lower tri of partial correlations.

cholesky

Logical. To return the cholesky decomposition instead of full covariance, set to TRUE.

Examples

1
2
3
4
5
testmat <- diag(exp(rnorm(5,-3,2)),5) #generate arbitrary std deviations
testmat[row(testmat) > col(testmat)] <- runif((5^2-5)/2, -1, 1) 
print(testmat)
covmat <- sdpcor2cov(testmat) #convert to covariance
cov2cor(covmat) #convert covariance to correlation

cdriveraus/ctsem documentation built on April 18, 2019, 9:51 a.m.