utils_pca {pliman} | R Documentation |
Utilities for Principal Component Axis analysis
Description
-
pca()
Computes a Principal Component Analysis. It wrappersstats::prcomp()
, but returns more results such as data, scores, contributions and quality of measurements for individuals and variables. -
get_biplot()
: Produces a biplot for an object computed withpca()
. -
plot.pca()
: Produces several types of plots, depending on thetype
andwhich
arguments.-
type = "var"
Produces a barplot with the contribution (which = "contrib"
), qualitity of adjustmentwhich = "cos2"
, and a scatter plot with coordinates (which = "coord"
) for the variables. -
type = "ind"
Produces a barplot with the contribution (which = "contrib"
), qualitity of adjustmentwhich = "cos2"
, and a scatter plot with coordinates (which = "coord"
) for the individuals. -
type = "biplot"
Produces a biplot.
-
Usage
pca(x, scale = TRUE)
get_biplot(
x,
axes = c(1, 2),
show = c("both"),
show_ind_id = TRUE,
show_unit_circle = TRUE,
expand = NULL
)
## S3 method for class 'pca'
plot(x, type = "var", which = "contrib", axis = 1, ...)
Arguments
x |
|
scale |
A logical value indicating whether the variables should be
scaled to have unit variance before the analysis takes place. Defaults to
|
axes |
The principal component axes to plot. Defaults to |
show |
Which to show in the biplot. Defaults to |
show_ind_id |
Shows the labels for individuals? Defaults to |
show_unit_circle |
Shows the unit variance circle? Defaults to |
expand |
An expansion factor to apply when plotting the second set of
points relative to the first. This can be used to tweak the scaling of the
two sets to a physically comparable scale. Setting to |
type |
One of |
which |
Which measure to plot. Either |
axis |
The axist to plot the contribution/cos2. Defaults to 1. |
... |
Further arguments passed on to |
Value
-
pca()
returns a list including:-
data
: The raw data used to compute the PCA. -
variances
: Variances (eigenvalues), and proportion of explained variance for each component. -
center,scale
: the centering and scaling used. -
ind,var
A list with the following objects for individuals/variables, respectively. -
coord
: coordinates for the individuals/variables (loadings * the component standard deviations) -
cos2
: cos2 for the individuals/variables (coord^2) -
contrib
: The contribution (in percentage) of a variable to a given principal component: (cos2 * 100) / (total cos2 of the component)
-
-
plot.pca()
returns a list with the coordinates used. -
get_biplot()
returns aNULL
object
Examples
library(pliman)
pc <- pca(mtcars[1:10 ,1:6])
plot(pc)
plot(pc, type = "ind")
plot(pc, type = "var", which = "coord")
plot(pc, type = "ind", which = "coord")
plot(pc, type = "biplot")