R: Compute Partial Correlation from Correlation Matrix - and...
cor2pcor
R Documentation
Compute Partial Correlation from Correlation Matrix – and Vice Versa
Description
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.
Usage
cor2pcor(m, tol)
pcor2cor(m, tol)
Arguments
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.
Details
The partial
correlations are the negative standardized concentrations (which in
turn are the off-diagonal elements of the inverse correlation or
covariance matrix). In graphical Gaussian models the partial
correlations represent the
direct interactions between two variables, conditioned on all
remaining variables.
In 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 advised to use pcor.shrink(x) and notcor2pcor(cor.shrink(x)).
Value
A matrix with the pairwise partial correlation coefficients
(cor2pcor) or with pairwise
correlations (pcor2cor).