prcomp
.prcomp(x, …)# S3 method for formula
prcomp(formula, data = NULL, subset, na.action, …)
# S3 method for default
prcomp(x, retx = TRUE, center = TRUE, scale. = FALSE,
tol = NULL, …)
# S3 method for prcomp
predict(object, newdata, …)
model.frame
) containing the variables in the
formula formula
. By default the variables are taken from
environment(formula)
.x
.x
is
a formula one might specify scale.
or tol
.x
can be supplied.
The value is passed to scale
.FALSE
for consistency with S, but
in general scaling is advisable. Alternatively, a vector of length
equal the number of columns of x
can be supplied. The
value is passed to scale
.tol
times the
standard deviation of the first component.)
With the default null setting, no components
are omitted. Other settings for tol could be tol = 0
or
tol = sqrt(.Machine$double.eps)
, which would omit
essentially constant components."prcomp"
newdata
must contain columns with the same
names. Otherwise it must contain the same number of columns, to be
used in the same order.
prcomp
returns a list with class "prcomp"
containing the following components:
princomp
returns this in the element loadings
.retx
is true the value of the rotated data (the
centred (and scaled if requested) data multiplied by the
rotation
matrix) is returned. Hence, cov(x)
is the
diagonal matrix diag(sdev^2)
. For the formula method,
napredict()
is applied to handle the treatment of values
omitted by the na.action
.FALSE
.eigen
on the covariance matrix. This
is generally the preferred method for numerical accuracy. The
print
method for these objects prints the results in a nice
format and the plot
method produces a scree plot. Unlike princomp
, variances are computed with the usual
divisor \(N - 1\). Note that scale = TRUE
cannot be used if there are zero or
constant (for center = TRUE
) variables.biplot.prcomp
, screeplot
,
princomp
, cor
, cov
,
svd
, eigen
.