FG: Flury-Gautschi (FG) algorithm

View source: R/FG.R

FGR Documentation

Flury-Gautschi (FG) algorithm

Description

The Flury-Gautschi (FG) algorithm for the simultaneous diagonalisation of several covariance matrices.

Usage

FG(covmats, nvec, method = c('ML', 'LS'))

Arguments

covmats

Array of covariance matrices to be simultaneously diagonalized, created by a command such as covmats <- array(NA, dim = c(p, p, k)).

nvec

Vector of sample sizes for the covariance matrices in covmats.

method

Estimation method to use, either Maximum Likelihood ('ML', default) or Least Squares ('LS').

Details

A modal matrix (B) is calculated for the covariance matrices under the assumption of common principal components in the populations. The common eigenvectors in B are ordered according to the sums of the associated eigenvalues in the k groups, from the largest sum to the smallest.

The default implementation uses maximum likelihood estimation as described in Flury (1988, p178). Least squares estimation, as described in Beaghen (1997, Appendix 2), is offered as an alternative.

Value

Returns a list with the values:

B

Orthogonal matrix containing the estimated common eigenvectors in the columns.

diagvals

Matrix of which the columns contain the estimated eigenvalues of the k covariance matrices under the CPC model.

Author(s)

Danie Uys, Theo Pepler, Adrian Schroeder

References

Flury, B. N. and Gautschi, W. (1986). An algorithm for simultaneous orthogonal transformation of several positive definite symmetric matrices to nearly diagonal form. SIAM Journal on Scientific and Statistical Computing, 7(1): 169-184.

Beaghen, M. (1997). Canonical Variate Analysis and Related Methods with Longitudinal Data. PhD dissertation, Virginia Polytechnic Institute and State University.

See Also

G.algorithm, stepwisecpc

Examples

# Setosa, Versicolor and Virginica groups of the Iris data
data(iris)
setosa <- iris[1:50, 1:4]
versicolor <- iris[51:100, 1:4]
virginica <- iris[101:150, 1:4]

# Create array containing the three covariance matrices
S <- array(NA, c(4, 4, 3))
S[, , 1] <- cov(setosa)
S[, , 2] <- cov(versicolor)
S[, , 3] <- cov(virginica)
nvec <- c(nrow(setosa), nrow(versicolor), nrow(virginica))

# Maximum likelihood estimates
cpc::FG(covmats = S, nvec = nvec)

# Least squares estimates
cpc::FG(covmats = S, nvec = nvec, method = 'LS')

tpepler/cpc documentation built on July 7, 2022, 2:13 a.m.