1

Here's my code :

mammal.pca_no.corr <- prcomp(PCA_mammal_dataset_no.corr, scale = T)
summary(mammal.pca)
mammal_pca_no.corr$rotation

And here's the output:

Importance of components:
                          PC1    PC2     PC3     PC4     PC5     PC6     PC7     PC8     PC9    PC10
Standard deviation     2.6653 1.4929 0.53917 0.35689 0.31104 0.29074 0.21260 0.12012 0.08043 0.04318
Proportion of Variance 0.7104 0.2229 0.02907 0.01274 0.00967 0.00845 0.00452 0.00144 0.00065 0.00019
Cumulative Proportion  0.7104 0.9333 0.96234 0.97508 0.98475 0.99320 0.99772 0.99917 0.99981 1.00000
                        PC1         PC2          PC3        PC4         PC5        PC6
adult_body_mass_g 0.2898569 -0.70308588 -0.375681954  0.1141424 -0.40480411  0.3219029
longevity_y       0.4473037 -0.01703924  0.509790194  0.7227587 -0.02265857 -0.1298056
adult_svl_cm      0.4151987 -0.42151638 -0.003714323 -0.3193357  0.61382852 -0.4137142
female_maturity_d 0.4521501  0.25324957  0.180901772 -0.2579211  0.24483079  0.7564616
male_maturity_d   0.4497617  0.22521078  0.161112601 -0.4673997 -0.62155166 -0.3409520
weaning_d         0.3698475  0.46135518 -0.735037761  0.2786222  0.11209906 -0.1410220

And here's the autoplot: [![enter image description here][1]][1]

Based on the output, I'll probably select PC1 and PC2. For PC2, the most prominent variable is the adult_body_mass, but what about PC1? All variables contribute to it relatively equally except for adult_body_mass and weaning_d. How should I interpret this?

  • "Eigenvector value squared has the meaning of the contribution of a variable into a pr. component" https://stats.stackexchange.com/a/143949/3277 – ttnphns Dec 04 '22 at 11:16

1 Answers1

2

We don't have your data so I can give you an example using mtcars. You could use the factoextra package with R to make everything easier. The components of the get_pca_var() can be used in the plot of variables as follow:

  • var$coord: coordinates of variables to create a scatter plot

  • var$cos2: represents the quality of representation for variables on the factor map. It’s calculated as the squared coordinates: var.cos2 = var.coord * var.coord.

  • var$contrib: contains the contributions (in percentage) of the variables to the principal components. The contribution of a variable (var) to a given principal component is (in percentage) : (var.cos2 * 100) / (total cos2 of the component).

The function fviz_contrib can be used to visualize the contribution of features to principal components. Here is a reproducible example:

library(factoextra)
data(mtcars)
car.pca <- prcomp(mtcars, scale = TRUE, center = TRUE)
var <- get_pca_var(car.pca)

head(var$contrib, 4) #> Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 Dim.6 #> mpg 13.14284 0.02599962 5.0960440 0.0508063075 1.0577029 1.1836881 #> cyl 13.98132 0.19135124 3.0734010 0.0006717622 0.3420355 2.8410348 #> disp 13.55603 0.24328694 0.3780299 6.5847606540 15.5232297 11.3006579 #> hp 10.89376 6.18934888 1.9604134 0.4580062170 29.1651238 0.5103049 #> Dim.7 Dim.8 Dim.9 Dim.10 Dim.11 #> mpg 1.352208e+01 56.865387485 5.555525 1.9400379 1.559892 #> cyl 3.280739e-01 5.328014619 0.291981 71.6425959 1.979521 #> disp 4.592581e+00 0.000130447 3.937361 0.2438363 43.640092 #> hp 2.237983e-04 4.944327640 33.158027 6.1416490 6.578818

Contributions of variables to PC1

fviz_contrib(car.pca, choice = "var", axes = 1, top = 10)

Created on 2022-12-02 with reprex v2.0.2


Check this source for extra info.

Quinten
  • 379
  • 1
  • 5
  • 17