pcorOrder {pcalg}R Documentation

Compute Partial Correlations

Description

This function computes partial correlations given a correlation matrix using a recursive algorithm or matrix inversion.

Usage

pcorOrder(i,j, k, C, cut.at = 0.9999999)

Arguments

i,j integer variable numbers to compute partial correlations of.
k conditioning set for partial correlations (vector of integers).
C correlation matrix (matrix)
cut.at number slightly smaller than one; if c is cut.at, values outside of [-c,c] are set to -c or c respectively.

Details

If the size of the conditioning sets is less than four, the partial correlations are computed recursively starting from the correlation matrix. If the size of the conditioning sets is greater than or equal to four, the partial correlations are computed by matrix inversion. This chooses in both cases the fastest method. To avoid numeric problems in recursions, the partial correlation is set to cut.at (= 0.9999999 by default; keep this value, unless you know better!), if it is above (e.g., if 1) and to -cut.at if it is below (e.g., if -1).

Value

The partial correlation of i and j given the set k.

Author(s)

Markus Kalisch kalisch@stat.math.ethz.ch and Martin Maechler

See Also

condIndFisherZ for testing zero partial correlation.

Examples

## produce uncorrelated normal random variables
mat <- matrix(rnorm(3*20),20,3)
## compute partial correlation of var1 and var2 given var3
pcorOrder(1,2, 3, cor(mat))

## define graphical model, simulate data and compute
## partial correlation with bigger conditional set
genDAG <- randomDAG(20, prob = 0.2)
dat <- rmvDAG(1000, genDAG)
C <- cor(dat)
pcorOrder(2,5, k = c(3,7,8,14,19), C)

[Package pcalg version 0.1-5 Index]