View source: R/utility_functions.R
stand_loadings | R Documentation |
Extract the standardized loadings from a prcomp object by correlating the PC scores and the original data.
stand_loadings(pca, pca_data)
pca |
Object of class prcomp, princals, or data.frame. If object is a prcomp or princals object, pca_data is required, and the loadings will be extracted. If object is a data.frame object, the dataframe needs to be formatted as: first column named Variables and all other columns corresponding to a PC. One row per variable. The values are the loadings. |
pca_data |
Data passed to the prcomp or princals function. |
The standardized loadings are calculated as the eigenvectors times the square roots of the respective eigenvalues and divided by the variable standard deviation (which is 1 in case of standardized PCA (from correlation matrix)). These are equivalent to the Pearson's correlation between the pca scores and the original dataset. This is the correlations of the PC with the variables and the same as the correlation of vector coefficients suggested by Jackson and Hearne in 1987.
This function extracts the standardized loadings from the output of the prcomp() or the princals() functions. In the case of the prcomp() solution, the standardized loadings are calculated as: s.loadings = eigenvectors x sqrt(eigenvalues) if the PCA was performed on the standardized (scaled to unit variance) data or s.loadings=(eigenvector x sqrt(eigenvalues))⁄S where S is the vector of the variables standard deviation. In the case of princals(), standardized loadings are returned directly in its output and therefore stand_loadings() returns those.
A data.frame with the standardized loadings in the form of variables as rows and components as columns.
Abel Torres Espin
Jackson JE, Hearne FT. Relationships Among Coefficients of Vectors Used In Principal Components. Technometrics. 1973 Aug 1;15(3):601–10.
data(mtcars) pca_mtcars<-prcomp(mtcars, center = TRUE, scale = TRUE) s.loadings<-stand_loadings(pca = pca_mtcars, pca_data = mtcars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.