cov2pcov: Partial Covariance Matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/cov2pcov.R

Description

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

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

Σ_{11.2} = Σ_{11} - Σ_{12} Σ_{22}^{-1} Σ_{21}

Σ_{22.1} = Σ_{22} - Σ_{21} Σ_{11}^{-1} Σ_{12}

Usage

1
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

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

# End (Not run)

biotools documentation built on Aug. 7, 2021, 9:06 a.m.