Function computing the partial correlation matrix or standardized precision matrix from an input precision matrix.

pcor(P, pc = TRUE)

Arguments

P

(Possibly regularized) precision matrix.

pc

A logical indicating if the partial correlation matrix should be computed.

Value

A partial correlation matrix or a standardized precision matrix.

Details

The function assumes that the input matrix is a precision matrix. If pc = FALSE the standardized precision matrix, rather than the partial correlation matrix, is given as the output value. The standardized precision matrix is equal to the partial correlation matrix up to the sign of off-diagonal entries.

See also

Author

Carel F.W. Peeters <carel.peeters@wur.nl>, Wessel N. van Wieringen

Examples


## Obtain some (high-dimensional) data
p = 25
n = 10
set.seed(333)
X = matrix(rnorm(n*p), nrow = n, ncol = p)
colnames(X)[1:25] = letters[1:25]
Cx <- covML(X)

## Obtain regularized precision matrix
P <- ridgeP(Cx, lambda = 10, type = "Alt")

## Obtain partial correlation matrix
pcor(P)
#> A 25 x 25 ridge precision matrix estimate with lambda = 10.000000
#>              a            b           c            d            e            f …
#> a  1.000000000  0.004284722  0.08180442  0.003301997 -0.023255824 -0.001036324 …
#> b  0.004284722  1.000000000  0.02534712  0.010534164  0.038818065 -0.008505235 …
#> c  0.081804421  0.025347119  1.00000000  0.048992900 -0.033888174 -0.020240055 …
#> d  0.003301997  0.010534164  0.04899290  1.000000000 -0.031578662 -0.002684267 …
#> e -0.023255824  0.038818065 -0.03388817 -0.031578662  1.000000000  0.009620035 …
#> f -0.001036324 -0.008505235 -0.02024006 -0.002684267  0.009620035  1.000000000 …
#> … 19 more rows and 19 more columns