AS Practice Exercise 3 Model Solution PDF
AS Practice Exercise 3 Model Solution PDF
There are several functions from different packages for performing PCA :
The functions prcomp() and princomp() from the built-in R stats package
PCA() from FactoMineR package. Read more here : PCA with FactoMineR
dudi.pca() from ade4 package. Read more here : PCA with ade4
Extract only active individuals and variables for principal component analysis:
decathlon2.active <- decathlon2[1:23, 1:10]
head(decathlon2.active[, 1:6])
X100m Long.jump Shot.put High.jump X400m X110m.hurdle
SEBRLE 11.04 7.58 14.83 2.07 49.81 14.69
CLAY 10.76 7.40 14.26 1.86 49.37 14.05
BERNARD 11.02 7.23 14.25 1.92 48.93 14.99
YURKOV 11.34 7.09 15.19 2.10 50.42 15.31
ZSIVOCZKY 11.13 7.30 13.48 2.01 48.62 14.17
McMULLEN 10.83 7.31 13.76 2.13 49.91 14.38
head(res.pca$sdev)
[1] 2.0308159 1.3559244 1.1131668 0.9052294 0.8375875 0.6502944
2. rotation : the matrix of variable loadings (columns are eigenvectors)
3.
head(unclass(res.pca$rotation)[, 1:4])
PC1 PC2 PC3 PC4
X100m -0.4188591 0.13230683 -0.2708996 0.03708806
Long.jump 0.3910648 -0.20713320 0.1711752 -0.12746997
Shot.put 0.3613881 -0.06298590 -0.4649778 0.14191803
High.jump 0.3004132 0.34309742 -0.2965280 0.15968342
X400m -0.3454786 -0.21400770 -0.2547084 0.47592968
X110m.hurdle -0.3762651 0.01824645 -0.4032525 -0.01866477
3. center, scale : the centering and scaling used, or FALSE