Principal component analysis (PCA) is a transformation of a
group of variables that produces a new set of artificial
features or components. These components are designed to capture
the maximum amount of information (i.e. variance) in the
original variables. Also, the components are statistically
independent from one another. This means that they can be used
to combat large inter-variables correlations in a data set.
It is advisable to standardize the variables prior to running
PCA. Here, each variable will be centered and scaled prior to
the PCA calculation. This can be changed using the
options
argument or by using step_center()
and step_scale()
.
The argument num_comp
controls the number of components that
will be retained (the original variables that are used to derive
the components are removed from the data). The new components
will have names that begin with prefix
and a sequence of
numbers. The variable names are padded with zeros. For example,
if num_comp < 10
, their names will be PC1
- PC9
.
If num_comp = 101
, the names would be PC001
-
PC101
.
Alternatively, threshold
can be used to determine the
number of components that are required to capture a specified
fraction of the total variance in the variables.
When you tidy()
this step, use either type = "coef"
for the variable
loadings per component or type = "variance"
for how much variance each
component accounts for.