Function to undertake an Exploratory Multivariate Data Analysis

Description

The function carries out a Principal Components Analysis (PCA) and estimates the Mahalanobis distances for a dataset and places them in an object to be saved and post-processed for display and further manipulation. Classical procedures are used, for robust procedures see gx.robmva. For results display see gx.rqpca.screeplot, gx.rqpca.loadplot, gx.rqpca.plot, gx.rqpca.print, gx.md.plot and gx.md.print. For Kaiser varimax rotation see gx.rotate. For closed. compositional, data use gx.mva.closed.

Usage

1
gx.mva(xx, main = deparse(substitute(xx)))

Arguments

xx

a n by p data matrix to be processed.

main

by default the name of the object xx, main = deparse(substitute(xx)), it may be replaced by the user, but this is not recommended, see Details below.

Details

If main is undefined the name of the matrix object passed to the function is used to identify the object. This is the recommended procedure as it helps to track the progression of a data analysis. Alternate plot titles are best defined when the saved object is passed to gx.rqpca.plot, gx.rqpca.screeplot or gx.md.plot for display. If no plot title is required set main = " ", or if a user defined plot title is required it may be defined, e.g., main = "Plot Title Text".

Value

The following are returned as an object to be saved for subsequent display, etc.:

main

by default (recommended) the input data matrix name.

input

the data matrix name, input = deparse(substitute(xx)), retained to be used by post-processing display functions.

proc

the procedure used, by default proc = "cov" to indicate a classical covariance matrix.

n

the total number of individuals (observations, cases or samples) in the input data matrix.

nc

the number of individuals remaining in the ‘core’ data subset after trimming. At this stage of a data analysis nc = n.

p

the number of variables on which the multivariate operations were based.

ifilr

flag for gx.md.plot, set to FALSE.

matnames

the row numbers or identifiers and column headings of the input matrix.

wts

the vector of weights for the n individuals used to compute the covariance matrix and means. At this stage of the data analysis all weights are set to ‘1’.

mean

the vector the weighted means for the p variables.

cov

the p by p weighted covariance matrix for the n by p data matrix.

sd

the vector of weighted standard deviations for the p variables.

snd

the n by p matrix of weighted standard normal deviates.

r

the p by p matrix of weighted Pearson product moment correlation coefficients.

eigenvalues

the vector of p eigenvalues of the scaled Pearson correlation matrix for RQ analysis, see Grunsky (2001).

econtrib

the vector of p eigenvalues each expressed as a percentage of the sum of the eigenvalues.

eigenvectors

the n by p matrix of eigenvectors.

rload

the p by p matrix of Principal Component (PC) loadings.

rcr

the p by p matrix containing the percentages of the variability of each variable (rows) expressed in each PC (columns).

rqscore

the n by p matrix of the n individuals scores on the p PCs.

vcontrib

a vector of p variances of the columns of rqscore.

pvcontrib

the vector of p variances of the columns of rqscore expressed as percentages. This is a check on vector econtrib, the values should be identical.

cpvcontrib

the vector of p cumulative sums of pvcontrib, see above.

md

the vector of n Mahalanobis distances (MDs) for the n by p input matrix.

ppm

the vector of n predicted probabilities of population membership, see Garrett (1990).

epm

the vector of n empirical Chi-square probabilities for the MDs.

nr

the number of PCs that have been rotated. At this stage of a data analysis nr = NULL in order to control PC plot axis labelling.

Note

Any less than detection limit values represented by negative values, or zeros or other numeric codes representing blanks in the data, must be removed prior to executing this function, see ltdl.fix.df.

Any rows in the data matrix with NAs are removed prior to computions. In the instance of a compositional data opening transformation NAs have to be removed prior to undertaking the transformation, see na.omit, where.na and remove.na. When that procedure is followed the opening transformations may be executed on calling the function, see Examples below.

Note that, executing a clr transformation leads to a singular matrix that can not be inverted for the estimation of Mahalanobis distances. In that case the values of md, ppm and epm are all set to NULL.

Note that, executing a ilr transformation permits the estimation of Mahalanobis distances and associated probabilities through the use of p-1 synthetic variables. However, in that instance the loadings of the p-1 synthetic variables will be plotted by gx.rqpca.plot rather than the loadings for the elements.

Therefore, use function gx.mva.closed for compositional, geochemical, data.

Warnings are generated when the number of individuals (observations, cases or samples) falls below 5p, and additional warnings when the number of individuals falls below 3p. At these low ratios of individuals to variables the shape of the p-space hyperellipsoid is difficult to reliably define, and therefor the results may lack stability. These limits 5p and 3p are generous, the latter especially so; many statisticians would argue that the number of individuals should not fall below 9p, see Garrett (1993).

Author(s)

Robert G. Garrett

References

Garrett, R.G., 1990. A robust multivariate allocation procedure with applications to geochemical data. In Proc. Colloquium on Statistical Applications in the Earth Sciences (Eds F.P. Agterberg & G.F. Bonham-Carter). Geological Survey of Canada Paper 89-9, pp. 309-318.

Garrett, R.G., 1993. Another cry from the heart. Explore - Assoc. Exploration Geochemists Newsletter, 81:9-14.

Grunsky, E.C., 2001. A program for computing RQ-mode principal components analysis for S-Plus and R. Computers & Geosciences, 27(2):229-235.

Reimann, C., Filzmoser, P., Garrett, R. and Dutter, R., 2008. Statistical Data Analysis Explained: Applied Environmental Statistics with R. John Wiley & Sons, Ltd., 362 p.

See Also

ltdl.fix.df, remove.na, na.omit, gx.rqpca.screeplot, gx.rqpca.loadplot, gx.rqpca.plot, gx.rqpca.print, gx.md.plot, gx.md.print, gx.robmva, gx.robmva.closed, gx.rotate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Make test data available
data(sind.mat2open)

## Generate gx.mva object, for demonstration purposes only
## These are compositional data - gx.mva.closed should be used
sind.save <- gx.mva(sind.mat2open)
gx.rqpca.screeplot(sind.save)
gx.rqpca.loadplot(sind.save)
gx.rqpca.plot(sind.save)
## Display saved object with alternate main titles
gx.rqpca.loadplot(sind.save,
main = "Howarth & Sinding-Larsen\nStream Sediments, clr Transformed Data",
cex.main = 0.8)
gx.rqpca.plot(sind.save,
main = "Howarth & Sinding-Larsen\nStream Sediments, clr Transformed Data",
cex.main = 0.8)

## Display Mahalanobis distances in a Chi-square plot
gx.md.plot(sind.save)
## Display saved object with alternate main titles
gx.md.plot(sind.save,
main = "Howarth & Sinding-Larsen\nStream Sediments, ilr Transformed Data",
cex.main = 0.8)

## Clean-up
rm(sind.save)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.