The Main purpose of PCA:
## Access_mentalhealthcare Access_physicalhealthcare Fear_healthcare
## 1 No change Increased Not applicable
## 2 Not applicable Not applicable No change
## 3 Not applicable Increased Decreased
## 4 No change No change No change
## 5 Not applicable Not applicable No change
## Refilling_prescription Use_health_care Use_mental_health_care
## 1 Increased Increased No change
## 2 No change No change No change
## 3 No change Decreased Decreased
## 4 No change No change No change
## 5 No change No change Not applicable
## Alcohol_consumption Exercise Hobbies Meditation Smoking
## 1 No change No change Increased No change No change
## 2 No change No change No change No change No change
## 3 No change Decreased Decreased Decreased Increased
## 4 No change Increased Increased Increased Not applicable
## 5 No change Not applicable No change Not applicable Not applicable
## Time_spent_outside Anxiety Anger Belief_system
## 1 No change Increased Not applicable Increased
## 2 No change No change No change No change
## 3 Decreased Increased Increased No change
## 4 No change No change No change No change
## 5 No change Not applicable Not applicable No change
## Control_over_life Social_isolation Stress Fear_seizure health_conditions
## 1 No change Increased Increased No change Not applicable
## 2 No change No change No change No change No change
## 3 Decreased Increased Increased Decreased No change
## 4 No change No change No change No change No change
## 5 No change Not applicable No change No change No change
## Access_mentalhealthcare Access_physicalhealthcare Fear_healthcare
## 1 0 1 0
## 2 0 0 0
## 3 0 1 -1
## 4 0 0 0
## 5 0 0 0
## Refilling_prescription Use_health_care Use_mental_health_care
## 1 1 1 0
## 2 0 0 0
## 3 0 -1 -1
## 4 0 0 0
## 5 0 0 0
## Alcohol_consumption Exercise Hobbies Meditation Smoking Time_spent_outside
## 1 0 0 1 0 0 0
## 2 0 0 0 0 0 0
## 3 0 -1 -1 -1 1 -1
## 4 0 1 1 1 0 0
## 5 0 0 0 0 0 0
## Anxiety Anger Belief_system Control_over_life Social_isolation Stress
## 1 1 0 1 0 1 1
## 2 0 0 0 0 0 0
## 3 1 1 0 -1 1 1
## 4 0 0 0 0 0 0
## 5 0 0 0 0 0 0
## Fear_seizure health_conditions
## 1 0 0
## 2 0 0
## 3 -1 0
## 4 0 0
## 5 0 0
## $coord
## Dim.1 Dim.2 Dim.3 Dim.4
## Access_mentalhealthcare -0.4644611 0.3955403 0.394130000 0.136231631
## Access_physicalhealthcare -0.4478290 0.3149727 0.479202921 0.262638318
## Fear_healthcare 0.4262164 0.3358117 -0.344210490 -0.046021571
## Refilling_prescription -0.2438876 0.5137290 -0.199604886 -0.040598744
## Use_health_care -0.4843698 0.4396098 0.352831635 -0.258295775
## Use_mental_health_care -0.3984736 0.4656767 0.289544287 -0.426154931
## Alcohol_consumption 0.2710838 0.1717173 0.244042450 0.502084567
## Exercise -0.2873934 0.4290606 -0.270660695 0.270884835
## Hobbies -0.3264089 0.4535660 -0.351480495 0.256315619
## Meditation -0.1633700 0.4957899 -0.497426283 0.092544501
## Smoking 0.4349985 0.3001447 0.443726485 0.007645219
## Time_spent_outside -0.3234186 0.2892604 -0.073045893 0.354331978
## Anxiety 0.6532310 0.3676307 0.007017362 0.101685413
## Anger 0.4958959 0.3328580 0.192639741 0.324170419
## Belief_system -0.1992540 0.4813176 -0.322476706 -0.164767445
## Control_over_life -0.4740484 0.3226489 0.029036834 -0.161069245
## Social_isolation 0.3852793 0.4285558 0.091722201 -0.364217882
## Stress 0.6594256 0.4734219 0.139216464 -0.024860886
## Fear_seizure 0.4444938 0.3415664 -0.239312164 -0.223680298
## health_conditions 0.4747114 0.3975873 0.113780876 -0.068966248
## Dim.5
## Access_mentalhealthcare -0.06804931
## Access_physicalhealthcare -0.23420304
## Fear_healthcare 0.42656920
## Refilling_prescription -0.29962125
## Use_health_care 0.22175640
## Use_mental_health_care 0.27656862
## Alcohol_consumption 0.50290470
## Exercise -0.02595583
## Hobbies -0.09479967
## Meditation 0.04007334
## Smoking -0.12191164
## Time_spent_outside 0.03401744
## Anxiety -0.12577637
## Anger 0.03129438
## Belief_system -0.24599375
## Control_over_life 0.35303358
## Social_isolation -0.25363329
## Stress -0.16660433
## Fear_seizure 0.27340166
## health_conditions -0.01447044
##
## $cor
## Dim.1 Dim.2 Dim.3 Dim.4
## Access_mentalhealthcare -0.4644611 0.3955403 0.394130000 0.136231631
## Access_physicalhealthcare -0.4478290 0.3149727 0.479202921 0.262638318
## Fear_healthcare 0.4262164 0.3358117 -0.344210490 -0.046021571
## Refilling_prescription -0.2438876 0.5137290 -0.199604886 -0.040598744
## Use_health_care -0.4843698 0.4396098 0.352831635 -0.258295775
## Use_mental_health_care -0.3984736 0.4656767 0.289544287 -0.426154931
## Alcohol_consumption 0.2710838 0.1717173 0.244042450 0.502084567
## Exercise -0.2873934 0.4290606 -0.270660695 0.270884835
## Hobbies -0.3264089 0.4535660 -0.351480495 0.256315619
## Meditation -0.1633700 0.4957899 -0.497426283 0.092544501
## Smoking 0.4349985 0.3001447 0.443726485 0.007645219
## Time_spent_outside -0.3234186 0.2892604 -0.073045893 0.354331978
## Anxiety 0.6532310 0.3676307 0.007017362 0.101685413
## Anger 0.4958959 0.3328580 0.192639741 0.324170419
## Belief_system -0.1992540 0.4813176 -0.322476706 -0.164767445
## Control_over_life -0.4740484 0.3226489 0.029036834 -0.161069245
## Social_isolation 0.3852793 0.4285558 0.091722201 -0.364217882
## Stress 0.6594256 0.4734219 0.139216464 -0.024860886
## Fear_seizure 0.4444938 0.3415664 -0.239312164 -0.223680298
## health_conditions 0.4747114 0.3975873 0.113780876 -0.068966248
## Dim.5
## Access_mentalhealthcare -0.06804931
## Access_physicalhealthcare -0.23420304
## Fear_healthcare 0.42656920
## Refilling_prescription -0.29962125
## Use_health_care 0.22175640
## Use_mental_health_care 0.27656862
## Alcohol_consumption 0.50290470
## Exercise -0.02595583
## Hobbies -0.09479967
## Meditation 0.04007334
## Smoking -0.12191164
## Time_spent_outside 0.03401744
## Anxiety -0.12577637
## Anger 0.03129438
## Belief_system -0.24599375
## Control_over_life 0.35303358
## Social_isolation -0.25363329
## Stress -0.16660433
## Fear_seizure 0.27340166
## health_conditions -0.01447044
##
## $cos2
## Dim.1 Dim.2 Dim.3 Dim.4
## Access_mentalhealthcare 0.21572412 0.15645211 1.553385e-01 1.855906e-02
## Access_physicalhealthcare 0.20055085 0.09920779 2.296354e-01 6.897889e-02
## Fear_healthcare 0.18166043 0.11276950 1.184809e-01 2.117985e-03
## Refilling_prescription 0.05948117 0.26391747 3.984211e-02 1.648258e-03
## Use_health_care 0.23461406 0.19325681 1.244902e-01 6.671671e-02
## Use_mental_health_care 0.15878121 0.21685481 8.383589e-02 1.816080e-01
## Alcohol_consumption 0.07348645 0.02948682 5.955672e-02 2.520889e-01
## Exercise 0.08259498 0.18409302 7.325721e-02 7.337859e-02
## Hobbies 0.10654280 0.20572210 1.235385e-01 6.569770e-02
## Meditation 0.02668977 0.24580763 2.474329e-01 8.564485e-03
## Smoking 0.18922372 0.09008682 1.968932e-01 5.844938e-05
## Time_spent_outside 0.10459962 0.08367160 5.335702e-03 1.255512e-01
## Anxiety 0.42671069 0.13515233 4.924336e-05 1.033992e-02
## Anger 0.24591273 0.11079448 3.711007e-02 1.050865e-01
## Belief_system 0.03970215 0.23166660 1.039912e-01 2.714831e-02
## Control_over_life 0.22472187 0.10410232 8.431377e-04 2.594330e-02
## Social_isolation 0.14844010 0.18366011 8.412962e-03 1.326547e-01
## Stress 0.43484219 0.22412830 1.938122e-02 6.180636e-04
## Fear_seizure 0.19757472 0.11666759 5.727031e-02 5.003288e-02
## health_conditions 0.22535094 0.15807565 1.294609e-02 4.756343e-03
## Dim.5
## Access_mentalhealthcare 0.0046307090
## Access_physicalhealthcare 0.0548510618
## Fear_healthcare 0.1819612866
## Refilling_prescription 0.0897728936
## Use_health_care 0.0491759021
## Use_mental_health_care 0.0764902031
## Alcohol_consumption 0.2529131411
## Exercise 0.0006737052
## Hobbies 0.0089869773
## Meditation 0.0016058725
## Smoking 0.0148624486
## Time_spent_outside 0.0011571864
## Anxiety 0.0158196959
## Anger 0.0009793381
## Belief_system 0.0605129231
## Control_over_life 0.1246327112
## Social_isolation 0.0643298457
## Stress 0.0277570014
## Fear_seizure 0.0747484675
## health_conditions 0.0002093936
##
## $contrib
## Dim.1 Dim.2 Dim.3 Dim.4
## Access_mentalhealthcare 6.030522 4.9737222 9.150251159 1.519306236
## Access_physicalhealthcare 5.606357 3.1538853 13.526733707 5.646841343
## Fear_healthcare 5.078279 3.5850216 6.979145139 0.173385307
## Refilling_prescription 1.662784 8.3901215 2.346909607 0.134931893
## Use_health_care 6.558587 6.1437697 7.333124561 5.461651866
## Use_mental_health_care 4.438695 6.8939667 4.938374578 14.867037776
## Alcohol_consumption 2.054298 0.9374066 3.508203518 20.636837948
## Exercise 2.308925 5.8524464 4.315234601 6.007016079
## Hobbies 2.978382 6.5400499 7.277068876 5.378232246
## Meditation 0.746107 7.8143969 14.575098064 0.701117245
## Smoking 5.289709 2.8639232 11.598043418 0.004784861
## Time_spent_outside 2.924060 2.6599790 0.314300906 10.278035338
## Anxiety 11.928607 4.2965873 0.002900693 0.846460545
## Anger 6.874439 3.5222341 2.185978065 8.602727630
## Belief_system 1.109865 7.3648437 6.125629500 2.222451158
## Control_over_life 6.282053 3.3094858 0.049665240 2.123805072
## Social_isolation 4.149612 5.8386838 0.495567669 10.859552765
## Stress 12.155922 7.1251960 1.141655894 0.050596748
## Fear_seizure 5.523160 3.7089445 3.373522228 4.095857829
## health_conditions 6.299638 5.0253358 0.762592575 0.389370114
## Dim.5
## Access_mentalhealthcare 0.41866299
## Access_physicalhealthcare 4.95909155
## Fear_healthcare 16.45114332
## Refilling_prescription 8.11637885
## Use_health_care 4.44599963
## Use_mental_health_care 6.91548910
## Alcohol_consumption 22.86590961
## Exercise 0.06090978
## Hobbies 0.81251378
## Meditation 0.14518714
## Smoking 1.34371589
## Time_spent_outside 0.10462138
## Anxiety 1.43026074
## Anger 0.08854208
## Belief_system 5.47098116
## Control_over_life 11.26805944
## Social_isolation 5.81606962
## Stress 2.50951407
## Fear_seizure 6.75801856
## health_conditions 0.01893130
The eigenvalues measure the amount of variation retained by each principal component. Eigenvalues are large for the first PCs and small for the subsequent PCs. That is, the first PCs corresponds to the directions with the maximum amount of variation in the data set.
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 3.5772046 17.886023 17.88602
## Dim.2 3.1455739 15.727869 33.61389
## Dim.3 1.6976415 8.488207 42.10210
## Dim.4 1.2215482 6.107741 48.20984
## Dim.5 1.1060708 5.530354 53.74019
## Dim.6 1.0591563 5.295782 59.03598
## Dim.7 0.9411249 4.705624 63.74160
## Dim.8 0.8702835 4.351417 68.09302
## Dim.9 0.7684707 3.842354 71.93537
## Dim.10 0.7090279 3.545140 75.48051
## Dim.11 0.6667696 3.333848 78.81436
## Dim.12 0.6107324 3.053662 81.86802
## Dim.13 0.5853772 2.926886 84.79491
## Dim.14 0.5663176 2.831588 87.62649
## Dim.15 0.5526440 2.763220 90.38971
## Dim.16 0.5311224 2.655612 93.04533
## Dim.17 0.4329637 2.164819 95.21014
## Dim.18 0.3685985 1.842993 97.05314
## Dim.19 0.3157372 1.578686 98.63182
## Dim.20 0.2736354 1.368177 100.00000
An eigenvalue > 1 indicates that PCs account for more variance than accounted by one of the original variables in standardized data. This is commonly used as a cutoff point for which PCs are retained. This holds true only when the data is standardized.
The PCA in the first step produced six dimensions with eigenvalues >than 1. These 6 dimensions accounted for 59% of the variance.
#Plot
get_pca_var provides a list of matrices containing all the results for the active variables (coordinates, correlation between variables and axes, squared cosine and contributions)
## Principal Component Analysis Results for variables
## ===================================================
## Name Description
## 1 "$coord" "Coordinates for the variables"
## 2 "$cor" "Correlations between variables and dimensions"
## 3 "$cos2" "Cos2 for the variables"
## 4 "$contrib" "contributions of the variables"
The correlation between a variable and a principal component is used as the coordinate of the variable on the PCA.
It shows the relationships between all variables. It can be interpreted as follow :
Positively correlated variables are grouped together. Negatively correlated variables are positioned on opposite sides of the plot origin (opposed quadrants). The distance between variables and the origin measures the quality of the variables on the factor map. Variables that are away from the origin are well represented on the factor map.
## Dim.1 Dim.2 Dim.3 Dim.4
## Access_mentalhealthcare -0.4644611 0.3955403 0.3941300 0.13623163
## Access_physicalhealthcare -0.4478290 0.3149727 0.4792029 0.26263832
## Fear_healthcare 0.4262164 0.3358117 -0.3442105 -0.04602157
## Refilling_prescription -0.2438876 0.5137290 -0.1996049 -0.04059874
## Use_health_care -0.4843698 0.4396098 0.3528316 -0.25829577
## Use_mental_health_care -0.3984736 0.4656767 0.2895443 -0.42615493
## Dim.5
## Access_mentalhealthcare -0.06804931
## Access_physicalhealthcare -0.23420304
## Fear_healthcare 0.42656920
## Refilling_prescription -0.29962125
## Use_health_care 0.22175640
## Use_mental_health_care 0.27656862
## Warning: ggrepel: 1 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
The quality of representation of the variables on factor map is called cos2 (square cosine, squared coordinates) . You can access to the cos2 as follow:
## Dim.1 Dim.2 Dim.3 Dim.4
## Access_mentalhealthcare 0.21572412 0.15645211 0.15533846 0.018559057
## Access_physicalhealthcare 0.20055085 0.09920779 0.22963544 0.068978886
## Fear_healthcare 0.18166043 0.11276950 0.11848086 0.002117985
## Refilling_prescription 0.05948117 0.26391747 0.03984211 0.001648258
## Use_health_care 0.23461406 0.19325681 0.12449016 0.066716707
## Use_mental_health_care 0.15878121 0.21685481 0.08383589 0.181608025
## Dim.5
## Access_mentalhealthcare 0.004630709
## Access_physicalhealthcare 0.054851062
## Fear_healthcare 0.181961287
## Refilling_prescription 0.089772894
## Use_health_care 0.049175902
## Use_mental_health_care 0.076490203
A high cos2 indicates a good representation of the variable on the principal component. In this case the variable is positioned close to the circumference of the correlation circle.
A low cos2 indicates that the variable is not perfectly represented
variables with low cos2 values will be colored in”white” variables with mid cos2 values will be colored in “blue” variables with high cos2 values will be colored in red
# Color by cos2 values: quality on the factor map
fviz_pca_var(res.pca, col.var = "cos2", labelsize = 2,
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
) +
theme(text = element_text(size = 4),
axis.title = element_text(size = 7.5),
axis.text = element_text(size = 7.5))
## Warning: ggrepel: 1 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
The contributions of variables in accounting for the variability in a given principal component are expressed in percentage. Variables that are correlated with PC1 (i.e., Dim. 1) and PC2 (i.e., Dim. 2) are the most important in explaining the variability in the data set. Variables that do not correlated with any PC or correlated with the last dimensions are variables with low contribution and might be removed to simplify the overall analysis. The contribution of variables can be extracted as follow :
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5
## Access_mentalhealthcare 6.030522 4.973722 9.150251 1.5193062 0.418663
## Access_physicalhealthcare 5.606357 3.153885 13.526734 5.6468413 4.959092
## Fear_healthcare 5.078279 3.585022 6.979145 0.1733853 16.451143
## Refilling_prescription 1.662784 8.390121 2.346910 0.1349319 8.116379
## Use_health_care 6.558587 6.143770 7.333125 5.4616519 4.446000
## Use_mental_health_care 4.438695 6.893967 4.938375 14.8670378 6.915489
The larger the value of the contribution, the more the variable contributes to the component.
Highlighting the most contributing variable for each column.
The red dashed line on the graph above indicates the expected average contribution. If the contribution of the variables were uniform, the expected value would be 1/ length( variables) = 1/ 10 = 10%. For a given component, a variable with a contribution larger than this cutoff could be considered as important in contributing to the component.
It can be seen that the variables AccessMHC,FearHCS,Going out, AccessPHC,Smoking,health,UsePHCS,Alcohol,Social Isolation,UseMHCS,Stress ,Controlon life - contribute the most to the dimensions 1 and 2.
The most important ( contributing variables can be highlighted in the correlation plot as)
## Warning: ggrepel: 1 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
## Warning: ggrepel: 1 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
We can identify the most significantly associated variables with a given principal component
## $quanti
## correlation p.value
## Stress 0.6594256 8.022223e-34
## Anxiety 0.6532310 5.112725e-33
## Anger 0.4958959 1.523092e-17
## health_conditions 0.4747114 5.108105e-16
## Fear_seizure 0.4444938 5.122685e-14
## Smoking 0.4349985 1.988698e-13
## Fear_healthcare 0.4262164 6.718639e-13
## Social_isolation 0.3852793 1.254836e-10
## Alcohol_consumption 0.2710838 9.279033e-06
## Meditation -0.1633700 8.307115e-03
## Belief_system -0.1992540 1.238592e-03
## Refilling_prescription -0.2438876 7.073760e-05
## Exercise -0.2873934 2.458718e-06
## Time_spent_outside -0.3234186 9.613630e-08
## Hobbies -0.3264089 7.201596e-08
## Use_mental_health_care -0.3984736 2.512607e-11
## Access_physicalhealthcare -0.4478290 3.149151e-14
## Access_mentalhealthcare -0.4644611 2.566653e-15
## Control_over_life -0.4740484 5.679681e-16
## Use_health_care -0.4843698 1.061268e-16
##
## attr(,"class")
## [1] "condes" "list"
## $quanti
## correlation p.value
## Refilling_prescription 0.5137290 6.515599e-19
## Meditation 0.4957899 1.551044e-17
## Belief_system 0.4813176 1.753138e-16
## Stress 0.4734219 6.277062e-16
## Use_mental_health_care 0.4656767 2.125405e-15
## Hobbies 0.4535660 1.346763e-14
## Use_health_care 0.4396098 1.034621e-13
## Exercise 0.4290606 4.546953e-13
## Social_isolation 0.4285558 4.874496e-13
## health_conditions 0.3975873 2.805553e-11
## Access_mentalhealthcare 0.3955403 3.614860e-11
## Anxiety 0.3676307 9.669517e-10
## Fear_seizure 0.3415664 1.586387e-08
## Fear_healthcare 0.3358117 2.844723e-08
## Anger 0.3328580 3.821377e-08
## Control_over_life 0.3226489 1.035053e-07
## Access_physicalhealthcare 0.3149727 2.137851e-07
## Smoking 0.3001447 8.201282e-07
## Time_spent_outside 0.2892604 2.100528e-06
## Alcohol_consumption 0.1717173 5.500397e-03
##
## attr(,"class")
## [1] "condes" "list"
## [1] 3.58 3.15 1.70 1.22 1.11 1.06 0.94 0.87 0.77 0.71 0.67 0.61 0.59 0.57 0.55
## [16] 0.53 0.43 0.37 0.32 0.27
## 'data.frame': 260 obs. of 20 variables:
## $ PC1 : num -1.71 -1.6 1.42 -2.22 -1.6 ...
## $ PC2 : num 2.798 -0.347 -1.555 0.853 -0.347 ...
## $ PC3 : num -0.284 -0.117 -3.152 1.234 -0.117 ...
## $ PC4 : num -0.3116 0.0233 0.9606 0.8525 0.0233 ...
## $ PC5 : num -1.7254 0.156 -3.4764 0.0542 0.156 ...
## $ PC6 : num 0.6594 0.0342 0.8807 -0.6107 0.0342 ...
## $ PC7 : num -1.109 0.042 -0.404 -0.208 0.042 ...
## $ PC8 : num -1.397 0.166 0.112 1.091 0.166 ...
## $ PC9 : num 0.5542 0.1534 0.8394 -0.0979 0.1534 ...
## $ PC10: num 0.00662 0.1151 -0.33483 -0.26156 0.1151 ...
## $ PC11: num -0.00896 0.04957 0.67422 0.09682 0.04957 ...
## $ PC12: num -1.1731 0.0434 -0.2029 -0.1714 0.0434 ...
## $ PC13: num -0.208 0.103 0.151 -0.4 0.103 ...
## $ PC14: num -0.3817 -0.0355 0.1321 0.4236 -0.0355 ...
## $ PC15: num -0.11 0.128 -0.326 0.369 0.128 ...
## $ PC16: num -0.105 -0.048 -1.032 0.553 -0.048 ...
## $ PC17: num -0.536 0.148 0.327 0.297 0.148 ...
## $ PC18: num -0.2987 0.0333 -0.3411 -0.4476 0.0333 ...
## $ PC19: num -0.38 0.1482 0.2143 0.0952 0.1482 ...
## $ PC20: num 0.1344 -0.0236 -0.1077 0.2373 -0.0236 ...
## PCs Variance
## 1 1 17.89
## 2 2 15.73
## 3 3 8.49
## 4 4 6.11
## 5 5 5.53
## 6 6 5.30
## 7 7 4.71
## 8 8 4.35
## 9 9 3.84
## 10 10 3.55
## 11 11 3.33
## 12 12 3.05
## 13 13 2.93
## 14 14 2.83
## 15 15 2.76
## 16 16 2.66
## 17 17 2.16
## 18 18 1.84
## 19 19 1.58
## 20 20 1.37