cor2pcor {corpcor} | R Documentation |
cor2pcor
computes the pairwise
partial correlation coefficients from either a correlation
or a covariance matrix.
pcor2cor
takes a partial correlation matrix and computes
the corresponding correlation matrix.
cor2pcor(m, exact.inversion=TRUE, check.eigenvalues=TRUE, tol) pcor2cor(m, exact.inversion=TRUE, check.eigenvalues=TRUE, tol)
m |
covariance matrix or (partial) correlation matrix |
check.eigenvalues |
if TRUE the input matrix is checked for positive definiteness (i.e. whether all eigenvalues are strictly postive) |
exact.inversion |
determines whether the inverse is computed
exactly (using solve ) or via pseudoinverse |
tol |
tolerance - singular values larger than
tol are considered non-zero (default value:
tol = max(dim(m))*max(D)*.Machine$double.eps ).
This values is used both for testing positive definiteness
as well as for computing the pseudoonverse.
|
The partial correlations represent the direct interactions between two variables, with the indirect effects of all remaining variables removed.
For computing partial correlation coefficients from data use the
function pcor.shrink
.
A matrix with the pairwise partial correlation coefficients
(cor2pcor
and pcor
) or with pairwise
correlations (pcor2cor
)
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 # 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 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 )