prcomp {mva} | R Documentation |
Principal Components Analysis
Description
Performs a principal components analysis on the given data matrix
and returns the results as a prcomp
object.
Usage
prcomp(x, retx = TRUE, center = TRUE, scale. = FALSE, tol = NULL)
Arguments
x |
a matrix (or data frame) which provides the data for the principal components analysis. |
retx |
a logical value indicating whether the rotated variables should be returned. |
center |
a logical value indicating whether the variables
should be shifted to be zero centered. Alternately, a vector of
length equal the number of columns of |
scale |
a logical value indicating whether the variables should
be scaled to have unit variance before the analysis takes
place. The default is |
tol |
a value indicating the magnitude below which components
should be omitted. With the default null setting, no components
are omitted. Other settings for tol could be |
Details
The calculation is done with svd on the data matrix, not by using eigen on the covariance matrix. This is generally the preferred method for numerical accuracy. The print method for the these objects prints the results in a nice format and the plot method produces a scree plot.
Value
prcomp
returns an list with class "prcomp"
containing the following components:
sdev |
the standard deviation of the principal components (i.e., the eigenvalues of the cov matrix, though the calculation is actually done with the singular values of the data matrix). |
rotation |
the matrix of variable loadings (i.e., a matrix
whose olumns contain the eigenvectors). The function
|
x |
if |
References
Mardia, K. V., J. T. Kent, J and M. Bibby (1979), Multivariate Analysis, London: Academic Press.
Venables, W. N. and B. D. Ripley (1997), Modern Applied Statistics with S-Plus, Springer-Verlag.
See Also
princomp
, cor
, cov
,
svd
, eigen
.
Examples
## the variances of the variables in the
## USArrests data vary by orders of magnitude
data(USArrests)
prcomp(USArrests)
prcomp(USArrests, scale = TRUE)
plot(prcomp(USArrests))
summary(prcomp(USArrests))