FG | R Documentation |
The Flury-Gautschi (FG) algorithm for the simultaneous diagonalisation of several covariance matrices.
FG(covmats, nvec, method = c('ML', 'LS'))
covmats |
Array of covariance matrices to be simultaneously diagonalized, created by a command such as |
nvec |
Vector of sample sizes for the covariance matrices in |
method |
Estimation method to use, either Maximum Likelihood ('ML', default) or Least Squares ('LS'). |
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.
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. |
Danie Uys, Theo Pepler, Adrian Schroeder
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.
G.algorithm
, stepwisecpc
# 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')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.