Rotation in 'FactoMineR' package
Asked Answered
R

2

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.

Remunerative answered 31/3, 2014 at 12:37 Comment(3)
Ah, PCA and rotation again. Perhaps this post will be of some help to you. stats.stackexchange.com/questions/612/…Darryldarryn
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.Remunerative
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.Bracer
A
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]),'/')
Alonso answered 27/6, 2016 at 15:7 Comment(1)
How can I apply varimax rotation?Liatris
I
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 = "/"
)
Incest answered 13/2, 2023 at 21:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.