princompDAS {DASplusR}R Documentation

Principal Component Analysis

Description

Performs principal component analysis on the given variables of a data set. The results are returned as an object of class "princomp".

Usage

princompDAS(data, vars, logVars = character(), subset, 
            cor = FALSE, robust = NULL, robargs = list(), 
            covmat = NULL, scores = TRUE)

Arguments

data A data object of class "DASData" or "data.frame".
vars A vector for selecting columns (variables) of data. It can be either a character vector containing the variable names, a numeric vector containing the column numbers or a logical vector. If missing, all columns of data are used.
logVars A subset of vars, specifying the columns (variables) of data to be log-transformed. Again, either a character vector containing the variable names, a numeric vector containing the column numbers or a logical vector can be supplied.
subset A vector for selecting the rows (observations) of data. It can be either a character, numeric or logical vector, too.
cor A logical value indicating whether the correlation matrix or the covariance matrix should be used for computing the principal components. The correlation matrix can only be used if there are no constant variables.
robust A character string containing the name of a function for computing a robust estimate of the covariance matrix, or the function itself. Examples are "covMcd" for MCD estimation and "covOGK" for OGK estimation. The function must take a matrix or a data frame as its first argument and should return a matrix, or a list that contains elements named center (an estimate for the central location) and cov (an estimate for the covariance matrix). Scores can only be computed in the latter case. If covmat is supplied as well, this argument is ignored.
robargs A list of additional arguments for the function specified by robust. The argument names should be used to name the list elements.
covmat A covariance matrix, or a covariance list as returned by cov.wt (or covMcd from package robustbase). If supplied, logVars and robust are ignored. Make sure that covmat has been calculated using the same data as defined by data, vars and subset. Scores can only be computed if covmat is a covariance list that also contains an estimate of the central location of the data.
scores A logical value indicating whether the scores on the principal components should be calculated. Supplying data and vars is necessary for calculating the scores.

Details

The principal components are computed by using eigen on the correlation or covariance matrix, as determined by cor. Note that for S-PLUS compatibility, the divisor N is used for non-robust calculation of the covariance matrix.

Observations that contain missing values are removed before computing the components. It is required that there are at least as many observations left after the removal as there are variables.

Value

princompDAS returns an object of class "princomp" that contains the following elements:

sdev The standard deviations of the principal components.
loadings The variable loadings (i.e., the matrix whose columns contain the eigenvectors of the correlation or covariance matrix). This is of class "loadings": see loadings for its print method.
center The means that were subtracted.
scale The scalings applied to each variable.
n.obs The number of observations.
scores The scores of the supplied data on the principal components, if requested.
call The matched function call.

Note

The signs of the columns of the loadings and scores are arbitrary, and so may differ between different programs for PCA, and even between different builds of R.

Author(s)

Andreas Alfons <andreas.alfons@student.tuwien.ac.at>

References

Mardia, K.V., Kent, J.T. and Bibby, J.M. (1979) Multivariate Analysis. Academic Press.

Johnson, R.A. and Wichern, D.W. (2002) Applied Multivariate Statistical Analysis. Prentice Hall. 5th edition.

Reimann, C., Filzmoser, P., Garrett, R.G. and Dutter, R. (2008) Statistical Data Analysis Explained. Wiley & Sons.

See Also

DAS+R functions: PrincompGUI, screeplotDAS, biplotDAS, factanalDAS.
R functions: princomp, eigen, covMcd, covOGK.

Examples

  ## KOLA95_Moss data
  data(KOLA95_MOSS)
  princompDAS(data = KOLA95_MOSS, 
              vars = c("Cu","Mg","Mn","Ni","Rb","Th"),
              logVars = c("Cu","Mg","Mn","Ni","Rb","Th"), 
              cor = TRUE, robust = "covMcd")

[Package DASplusR version 0.0-1 Index]