Home:ALL Converter>Predict() new data into PCA space in R

Predict() new data into PCA space in R

Ask Time:2017-10-19T19:06:01         Author:user 123342

Json Formatter

After performing a principal component analysis of a first data set (a), I projected a second data set (b) into PCA space of the first data set.

From this, I want to extract the variable loadings for the projected analysis of (b). Variable loadings of the PCA of (a) are returned by prcomp(). How can I retrieve the variable loadings of (b), projected into PCA space of (a)?

# set seed and define variables
set.seed(1)
a = replicate(10, rnorm(10))
b = replicate (10, rnorm(10))

# pca of data A and project B into PCA space of A
pca.a = prcomp(a)
project.b = predict(pca.a, b)

# variable loadings
loads.a = pca.a$rotation

Author:user 123342,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46828500/predict-new-data-into-pca-space-in-r
yy