cov2pcov {biotools}R Documentation

Partial Covariance Matrix

Description

Compute a matrix of partial (co)variances for a group of variables with respect to another.

Take Σ\Sigma as the covariance matrix of dimension p. Now consider dividing Σ\Sigma into two groups of variables. The partial covariance matrices are calculate by:

Σ11.2=Σ11Σ12Σ221Σ21 \Sigma_{11.2} = \Sigma_{11} - \Sigma_{12} \Sigma_{22}^{-1} \Sigma_{21}

Σ22.1=Σ22Σ21Σ111Σ12 \Sigma_{22.1} = \Sigma_{22} - \Sigma_{21} \Sigma_{11}^{-1} \Sigma_{12}

Usage

cov2pcov(m, vars1, vars2 = seq(1, ncol(m))[-vars1])

Arguments

m

a square numeric matrix.

vars1

a numeric vector indicating the position (rows or columns in m) of the set of variables at which to compute the partial covariance matrix.

vars2

a numeric vector indicating the position (rows or columns in m) of the set of variables at which to adjust the partial covariance matrix.

Value

A square numeric matrix.

Author(s)

Anderson Rodrigo da Silva <anderson.agro at hotmail.com>

See Also

cov

Examples

(Cl <- cov(longley))
cov2pcov(Cl, 1:2)

# End (Not run)

[Package biotools version 4.2 Index]