cor2pcor {corpcor} | R Documentation |
cor2pcor
computes the pairwise
partial correlation coefficients from either a correlation
or a covariance matrix.
pcor2cor
takes either a partial correlation matrix or
a partial covariance matrix as input,
and computes from it the corresponding correlation matrix.
cov2pcov
transform a covariance matrix into a partial
covariance matrix, and pcov2cov
is the corresponding
reciprocal operation.
cor2pcor(m, tol) pcor2cor(m, tol) cov2pcov(m, tol) pcov2cov(m, tol)
m |
covariance matrix or (partial) correlation matrix |
tol |
tolerance - singular values larger than
tol are considered non-zero (default value:
tol = max(dim(m))*max(D)*.Machine$double.eps ).
This parameter is needed for the singular
value decomposition on which pseudoinverse is based.
|
The partial covariance is the inverse of the covariance matrix, with the signs of the off-diagonal elements reversed. The partial correlation is the standardized partial covariance matrix.
In graphical Gaussian models the partial correlations represent the direct interactions between two variables, conditioned on all remaining variables.
In all the above functions the pseudoinverse
is employed
for inversion - hence even singular covariances (with some
zero eigenvalues) may be used. However, a better option may be to
estimate a positive definite covariance matrix using
cov.shrink
.
Note that for efficient computation of partial correlation coefficients from data
x
it is recommend to employ pcor.shrink(x)
, and *not*
cor2pcor(cor.shrink(x))
.
A matrix with the pairwise partial correlation coefficients
(cor2pcor
), with pairwise
correlations (pcor2cor
), with the partial covariances (cov2pcor
),
or the covariances (pcov2cov
).
Korbinian Strimmer (http://www.statistik.lmu.de/~strimmer/).
Whittaker J. (1990). Graphical Models in Applied Multivariate Statistics. John Wiley, Chichester.
# load corpcor library library("corpcor") # covariance matrix m.cov <- rbind( c(3,1,1,0), c(1,3,0,1), c(1,0,2,0), c(0,1,0,2) ) m.cov # partial covariance matrix m.pcov <- cov2pcov(m.cov) m.pcov # corresponding correlation matrix m.cor.1 <- cov2cor(m.cov) m.cor.1 # compute partial correlations (from covariance matrix) m.pcor.1 <- cor2pcor(m.cov) m.pcor.1 # compute partial correlations (from correlation matrix) m.pcor.2 <- cor2pcor(m.cor.1) m.pcor.2 # compute partial correlations (from partial covariance matrix) m.pcor.3 <- cov2cor(m.pcov) m.pcor.3 zapsmall( m.pcor.1 ) == zapsmall( m.pcor.2 ) # backtransformation m.cor.2 <- pcor2cor(m.pcor.1) m.cor.2 zapsmall( m.cor.1 ) == zapsmall( m.cor.2 )