9

Thanks in advance. I've used the 'PCA' function from the 'FactoMineR' package to obtain principal component scores. I've tried reading through the package details and similar questions on this forum but can't figure out the code to rotate the extracted components (either orthogonal or oblique).

I know the 'princomp' function and the 'principal' function in the 'psych' package have rotating abilities but I really like the ability in 'PCA' to scale the variables to unit-variance. Any help would be appreciated. Thank you.

gtnbz2nyt
  • 1,465
  • 3
  • 17
  • 33
  • Ah, PCA and rotation again. Perhaps this post will be of some help to you. http://stats.stackexchange.com/questions/612/is-psychprincipal-function-still-pca-when-using-rotation – Roman Luštrik Mar 31 '14 at 12:50
  • Thanks for the link. I know the particular packages discussed have rotation, but they don't don't have the ability to natively scale variables or include supplemental data like 'PCA'. I did some other reading and found that 'prcomp' can both rotate and scale, but can't include supplemental info. Is there a one-stop shop for all of these abilities in one function? Thanks. – gtnbz2nyt Mar 31 '14 at 13:03
  • Any update on this? I want to do an oblique rotation on results from mixed data (numeric + categorical). Both FAMD and and PCAmix from PCAmixdata package seem to support mixed data, but couldnt find a good way of doing an oblique rotation. – Thusitha Dec 26 '17 at 05:45

2 Answers2

3

IIUC:

library(FactoMineR)
data(iris)
Iris <- iris[,1:4]
res <- PCA(Iris, graph=F)
#rotation
t(apply(res$var$coord, 1, function(x) {x/sqrt(res$eig[,1])}))
                  Dim.1      Dim.2      Dim.3      Dim.4
Sepal.Length  0.5210659 0.37741762 -0.7195664 -0.2612863
Sepal.Width  -0.2693474 0.92329566  0.2443818  0.1235096
Petal.Length  0.5804131 0.02449161  0.1421264  0.8014492
Petal.Width   0.5648565 0.06694199  0.6342727 -0.5235971

#check
prcomp(Iris, scale=T)
Rotation:
                    PC1         PC2        PC3        PC4
Sepal.Length  0.5210659 -0.37741762  0.7195664  0.2612863
Sepal.Width  -0.2693474 -0.92329566 -0.2443818 -0.1235096
Petal.Length  0.5804131 -0.02449161 -0.1421264 -0.8014492
Petal.Width   0.5648565 -0.06694199 -0.6342727  0.5235971

An alternative line of code, if you wish to obtain loadings from PCA object:

sweep(res$var$coord, 2, sqrt(res$eig[,1]),'/')
Sergey Bushmanov
  • 23,310
  • 7
  • 53
  • 72
0

I have the same need here. I want to do a rotation with FactominR, but the answer above just gives me the original loadings.

http://factominer.free.fr/question/FAQ.html

sweep(
  res.pca$var$coord,
  2, 
  sqrt(res.pca$eig[1:ncol(res.pca$var$coord), 1]),
  FUN = "/"
)
jyr
  • 690
  • 6
  • 20
Tehachapi
  • 1
  • 1