0% found this document useful (0 votes)
11 views2 pages

PCA Analysis in R with FactoMineR

Uploaded by

Rouaida Hentati
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

PCA Analysis in R with FactoMineR

Uploaded by

Rouaida Hentati
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PCA Codes

installing package
[Link](‘FactoMineR’)
Library(FactoMineR)
data(decathlon)

FactoMineR is an R package dedicated to multivariate Exploratory Data


Analysis. It is developed and maintained by François Husson, Julie Josse,
Sébastien Lê, d'Agrocampus Rennes, and J. Mazet.

perform PCA analysis


[Link] = PCA(decathlon[,1:10], [Link]=TRUE, ncp=5, graph=T)
to choose whether to number of dimensions to choose whether to
scale the data or not kept in the result plot the graphs or not

The first two dimensions resume 50% of the total inertia


=> The variable "X100m" is correlated negatively to the variable "[Link]". When an ahtlete performs a
short time when running 100m, he can jump a big distance.
=> The first axis opposes athletes who are "good everywhere" like Karpov during the Olympic Games between
those who are "bad everywhere" like Bourguignon during the Decastar.
The second axis opposes athletes who are strong (variables "Discus" and "[Link]") between those who are
not.
=> The variables "Discus", "[Link]" and "[Link]" are not much correlated to the variables "X100m",
"X400m", "[Link]" and "[Link]". This means that strength is not much correlated to speed.
=> At the end of this first approach, we can divide the factorial plan into four parts: fast and strong athletes
(like Sebrle), slow athletes (like Casarsa), fast but weak athletes (like Warners) and slow and weak (relatively
speaking!) athletes (like Lorenzo).
supplementary variables (continuous ones / categorical)
Supplementary variables have no influence on the principal components of the analysis. They are going to
help to interpret the dimensions of variability.
[Link] = PCA(decathlon[,1:12], [Link]=TRUE, ncp=5, [Link]=c(11: 12), [Link]=13,
graph=T)
a colour for each individual ("ind")
[Link]([Link], axes=c(1, 2), choix="ind", habillage=13)

the graph to plot ("ind" to choose the colours of to colour the individuals according to a categorical
for the individuals, "var" the individuals variable (give the number of the qualitative variable)
for the variables)
no colour ("none")
describe the dimensions
dimdesc([Link], axes=c(1,2))
calculates the correlation coefficient between a variable an a dimension and performs a significance test
Both active and supplementary variables whose p-value is smaller than
0.05 appear.
=> The variables "Points" and "[Link]" are the most correlated to the
first dimension

To add supplementary individuals, use the following argument of


the PCA function:
[Link]
Detailed results
All the detailed results can be found in [Link]. We can get the eigenvalues, the results of the active
and supplementary individuals, the results of the active variables and the results of the categorical
and continuous supplementary variables by typing:

[Link]
names([Link])
[Link]$eig, [Link]$ind, [Link]$[Link], [Link]$var,
[Link]$[Link], [Link]$[Link]
weight of the individuals
In most PCAs, the weight of the individuals is equal to 1/(number of individuals).
However, it is sometimes necessary to give a specific weight to some individuals.
To do so, the user will have to use the argument:

row.w

It can also be interesting to give a specific weight to some variables.


Here, the user will have to use the argument:

col.w

To see whether the categories of the supplementary variable are significantly


different from each other, we can draw confidence ellipses around them.
To do so, type:

plotellipses([Link])

You might also like