Graph for PCA

42 views
Skip to first unread message

Mahmood Naderan

unread,
Mar 9, 2021, 6:26:36 AM3/9/21
to factomin...@googlegroups.com
Hi,
When I use PCA() with graph=T I see two separate graphs, one for individuals and one for variables.
Is it possible to have both in one graph, which is called biplot?

Regards,
Mahmood



Meinhard H. Schroeder

unread,
Mar 9, 2021, 6:50:12 AM3/9/21
to factomin...@googlegroups.com

Yes, it’s possible with the package factoextra.

 

http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/112-pca-principal-component-analysis-essentials/#biplot

 

install.packages("FactoMineR")

library("factoextra")

library("FactoMineR")

decathlon2.active <- decathlon2[1:23, 1:10]

head(decathlon2.active[, 1:6], 4)

res.pca <- PCA(decathlon2.active, graph = FALSE)

 

fviz_pca_biplot(res.pca, repel = TRUE,

                col.var = "#2E9FDF", # Variables color

                col.ind = "#696969"  # Individuals color

)

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "FactoMineR users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse factominer-use...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/factominer-users/CADa2P2XCVQvwz_%2B_MZQtkhCjAVwPXEsduK5gsWY-wXJcbfJFJw%40mail.gmail.com.

Francois Husson

unread,
Mar 11, 2021, 7:50:51 AM3/11/21
to factomin...@googlegroups.com
Hi,
This biplot representation is not proposed in FactoMineR because it is subject to too many misinterpretations. Voluntarily, it is not proposed.
FH
--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "FactoMineR users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse factominer-use...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/factominer-users/CADa2P2XCVQvwz_%2B_MZQtkhCjAVwPXEsduK5gsWY-wXJcbfJFJw%40mail.gmail.com.

--
Francois Husson
Department Statistics & Computer science
L'Institut Agro - AGROCAMPUS OUEST
65 rue de St-Brieuc - 35042 RENNES
Tel: +33 2 23 48 58 86
https://husson.github.io

Mahmood Naderan

unread,
Mar 12, 2021, 6:03:00 AM3/12/21
to factomin...@googlegroups.com
Thanks but it seems that your method doesn't show the qualitative variables.
Please see the picture at https://pasteboard.co/JROiQYi.png

> mydata <- read.csv('test.csv', header=T,row.names=1)
> mydata
     V1  V2   V3  V4 CTG
P1 73.6 0.7 74.6 3.1  A1
P2 75.2 0.7 75.8 2.8  B1
P3  6.5 0.0  7.3 2.5  B1
P4 41.4 0.3 39.2 8.9  C1
P5  5.4 0.1 18.2 1.1  A1
P6 18.8 0.3 30.3 7.3  C1
> res.pca = PCA(mydata, quali.sup=5, graph=F)
> plot(res.pca, choix="ind")
> fviz_pca_biplot(res.pca, repel = TRUE, col.var = "#FF0000", col.ind = "#0000FF")
Regards,
Mahmood





Reply all
Reply to author
Forward
0 new messages