Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 2 |
m |
covariance matrix or (partial) correlation matrix |
tol |
tolerance - singular values larger than
tol are considered non-zero (default value:
|
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 not
cor2pcor(cor.shrink(x))
.
A matrix with the pairwise partial correlation coefficients
(cor2pcor
) or with pairwise
correlations (pcor2cor
).
Korbinian Strimmer (https://strimmerlab.github.io).
Whittaker J. 1990. Graphical Models in Applied Multivariate Statistics. John Wiley, Chichester.
decompose.invcov
, pcor.shrink
, pseudoinverse
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # 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 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.