flury.test | R Documentation |
Calculates the AIC and chi square statistics for all the applicable models in Flury's hierarchy of covariance structures for several covariance matrices.
flury.test(covmats, nvec, B = cpc::FG(covmats = covmats, nvec = nvec)$B, p = dim(covmats)[1], qmax = p - 2, commonvec.order = findcpc(covmats = covmats, B = B, plotting = FALSE)$commonvec.order)
covmats |
Array of covariance matrices to be tested, created by a command such as |
nvec |
Vector of sample sizes of the k groups. |
B |
Modal matrix, i.e. the orthogonal p x p matrix diagonalising the k covariance matrices simultaneously under the assumption of common principal components. Can be estimated using simultaneous diagonalisation algorithms such as the Flury-Gautschi (implemented in |
p |
Number of columns/variables in the covariance matrix. |
qmax |
Maximum number of common eigenvectors for which to estimate the partial CPC model statistics. |
commonvec.order |
Vector indicating the order of the most likely candidates of common eigenvectors – from 1 (most likely) to p (least likely). |
Returns a data frame with the following columns, containing a value for each of the models in Flury's hierarchy:
Model |
Name of the model in Flury's hierarchy. |
Chi.square |
Chi square statistic for the model. |
DF |
Degrees of freedom associated with the chi square statistic. |
Chi2.div.df |
The chi square statistic divided by its degrees of freedom. |
AIC |
Akaike Information Criterion for the model. |
No.of.CPCs |
Number of common eigenvectors for the model. |
Flury (1988) suggested picking the model with the smallest AIC value. Alternatively one may select the model for which the chi square statistic divided by its degrees of freedom is closest to one, although Flury (and others) cautions against this practice as the chi square statistics for the models are probably not independent of one another.
Theo Pepler
Flury, B. (1988). Common Principal Components and Related Multivariate Models. Wiley.
flury.AIC
, equal.test
, prop.test
, cpc.test
and cpcq.test
# Versicolor and virginica groups of the Iris data data(iris) versicolor <- iris[51:100, 1:4] virginica <- iris[101:150, 1:4] # Create array containing the two covariance matrices S <- array(NA, c(4, 4, 2)) S[, , 1] <- cov(versicolor) S[, , 2] <- cov(virginica) nvec <- c(nrow(versicolor), nrow(virginica)) flury.test(covmats = S, nvec = nvec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.