Learn R Programming

parameters (version 0.1.0)

principal_components: Principal Component Analysis (PCA)

Description

This function performs a principal component analysis (PCA) and returns the loadings (of the unrotated matrix) as dataframe.

Usage

principal_components(x, n = NULL, rotation = "none", sort = FALSE,
  threshold = NULL, standardize = TRUE, ...)

PCA(x, n = NULL, rotation = "none", sort = FALSE, threshold = NULL, standardize = TRUE, ...)

Arguments

x

A dataframe.

n

Number of components to extract. If n = NULL, the number of components is selected through n_factors.

rotation

If not "none", the PCA will be computed using the psych package. Possible options include "varimax", "quartimax", "promax", "oblimin", "simplimax", and "cluster". See fa for details.

sort

Sort the loadings.

threshold

A value between 0 and 1 indicates which (absolute) values from the loadings should be removed. Can also be "max", in which case it will only display the maximum loading per veriable (the most simple structure).

standardize

A logical value indicating whether the variables should be standardized (centred and scaled) to have unit variance before the analysis takes place (in general, such scaling is advisable).

...

Arguments passed to or from other methods.

Value

A data.frame of loadings.

Details

  • Complexity (Hoffman's, 1978; Pettersson and Turkheimer, 2010) represents the number of latent components needed to account for the observed variables. Whereas a perfect simple structure solution has a complexity of 1 in that each item would only load on one factor, a solution with evenly distributed items has a complexity greater than 1.

References

  • Pettersson, E., & Turkheimer, E. (2010). Item selection, evaluation, and simple structure in personality data. Journal of research in personality, 44(4), 407-420.

Examples

Run this code
# NOT RUN {
library(parameters)

principal_components(mtcars[, 1:7], n = "all", threshold = 0.2)
principal_components(mtcars[, 1:7], n = 2, rotation = "oblimin", threshold = "max", sort = TRUE)

pca <- principal_components(mtcars[, 1:5], n = 2)
summary(pca)
predict(pca)
# }
# NOT RUN {
# Automated number of components
principal_components(mtcars[, 1:4])
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab