Load Library

library(ggrepel)
library(psych)
library(sjPlot)
library(ppcor)
library(factoextra)
library(corrplot)
library(FactoMineR)
library(dplyr)

Import Data

data <- read.csv("WHR2023.csv")
str(data)
## 'data.frame':    137 obs. of  19 variables:
##  $ Country.name                              : chr  "Finland" "Denmark" "Iceland" "Israel" ...
##  $ Ladder.score                              : num  7.8 7.59 7.53 7.47 7.4 ...
##  $ Standard.error.of.ladder.score            : num  0.036 0.041 0.049 0.032 0.029 0.037 0.044 0.043 0.069 0.038 ...
##  $ upperwhisker                              : num  7.88 7.67 7.62 7.54 7.46 ...
##  $ lowerwhisker                              : num  7.73 7.51 7.43 7.41 7.35 ...
##  $ Logged.GDP.per.capita                     : num  10.8 11 10.9 10.6 10.9 ...
##  $ Social.support                            : num  0.969 0.954 0.983 0.943 0.93 0.939 0.943 0.92 0.879 0.952 ...
##  $ Healthy.life.expectancy                   : num  71.2 71.2 72 72.7 71.5 ...
##  $ Freedom.to.make.life.choices              : num  0.961 0.934 0.936 0.809 0.887 0.948 0.947 0.891 0.915 0.887 ...
##  $ Generosity                                : num  -0.019 0.134 0.211 -0.023 0.213 0.165 0.141 0.027 0.024 0.175 ...
##  $ Perceptions.of.corruption                 : num  0.182 0.196 0.668 0.708 0.379 0.202 0.283 0.266 0.345 0.271 ...
##  $ Ladder.score.in.Dystopia                  : num  1.78 1.78 1.78 1.78 1.78 ...
##  $ Explained.by..Log.GDP.per.capita          : num  1.89 1.95 1.93 1.83 1.94 ...
##  $ Explained.by..Social.support              : num  1.58 1.55 1.62 1.52 1.49 ...
##  $ Explained.by..Healthy.life.expectancy     : num  0.535 0.537 0.559 0.577 0.545 0.562 0.544 0.582 0.549 0.513 ...
##  $ Explained.by..Freedom.to.make.life.choices: num  0.772 0.734 0.738 0.569 0.672 0.754 0.752 0.678 0.71 0.672 ...
##  $ Explained.by..Generosity                  : num  0.126 0.208 0.25 0.124 0.251 0.225 0.212 0.151 0.149 0.23 ...
##  $ Explained.by..Perceptions.of.corruption   : num  0.535 0.525 0.187 0.158 0.394 0.52 0.463 0.475 0.418 0.471 ...
##  $ Dystopia...residual                       : num  2.36 2.08 2.25 2.69 2.11 ...

Ambil Data Numerik

data_num <- data[, sapply(data, is.numeric)]
dim(data_num)
## [1] 137  18

Cleaning Data

colSums(is.na(data_num))
##                               Ladder.score 
##                                          0 
##             Standard.error.of.ladder.score 
##                                          0 
##                               upperwhisker 
##                                          0 
##                               lowerwhisker 
##                                          0 
##                      Logged.GDP.per.capita 
##                                          0 
##                             Social.support 
##                                          0 
##                    Healthy.life.expectancy 
##                                          1 
##               Freedom.to.make.life.choices 
##                                          0 
##                                 Generosity 
##                                          0 
##                  Perceptions.of.corruption 
##                                          0 
##                   Ladder.score.in.Dystopia 
##                                          0 
##           Explained.by..Log.GDP.per.capita 
##                                          0 
##               Explained.by..Social.support 
##                                          0 
##      Explained.by..Healthy.life.expectancy 
##                                          1 
## Explained.by..Freedom.to.make.life.choices 
##                                          0 
##                   Explained.by..Generosity 
##                                          0 
##    Explained.by..Perceptions.of.corruption 
##                                          0 
##                        Dystopia...residual 
##                                          1
data_num <- na.omit(data_num)

apply(data_num, 2, sd)
##                               Ladder.score 
##                                 1.14284053 
##             Standard.error.of.ladder.score 
##                                 0.02299565 
##                               upperwhisker 
##                                 1.12044167 
##                               lowerwhisker 
##                                 1.16652219 
##                      Logged.GDP.per.capita 
##                                 1.21010663 
##                             Social.support 
##                                 0.12959657 
##                    Healthy.life.expectancy 
##                                 5.75039035 
##               Freedom.to.make.life.choices 
##                                 0.11249764 
##                                 Generosity 
##                                 0.14160355 
##                  Perceptions.of.corruption 
##                                 0.17735282 
##                   Ladder.score.in.Dystopia 
##                                 0.00000000 
##           Explained.by..Log.GDP.per.capita 
##                                 0.43396909 
##               Explained.by..Social.support 
##                                 0.32726285 
##      Explained.by..Healthy.life.expectancy 
##                                 0.15669110 
## Explained.by..Freedom.to.make.life.choices 
##                                 0.14967122 
##                   Explained.by..Generosity 
##                                 0.07599332 
##    Explained.by..Perceptions.of.corruption 
##                                 0.12700872 
##                        Dystopia...residual 
##                                 0.50439005
data_num <- data_num[, apply(data_num, 2, sd) > 0]

Rasio Sampel

n <- nrow(data_num)
p <- ncol(data_num)

n
## [1] 136
p
## [1] 17
n/p
## [1] 8

Matriks Korelasi

mat_corr <- cor(data_num)
round(mat_corr,2)
##                                            Ladder.score
## Ladder.score                                       1.00
## Standard.error.of.ladder.score                    -0.51
## upperwhisker                                       1.00
## lowerwhisker                                       1.00
## Logged.GDP.per.capita                              0.78
## Social.support                                     0.84
## Healthy.life.expectancy                            0.75
## Freedom.to.make.life.choices                       0.66
## Generosity                                         0.04
## Perceptions.of.corruption                         -0.47
## Explained.by..Log.GDP.per.capita                   0.78
## Explained.by..Social.support                       0.84
## Explained.by..Healthy.life.expectancy              0.75
## Explained.by..Freedom.to.make.life.choices         0.66
## Explained.by..Generosity                           0.04
## Explained.by..Perceptions.of.corruption            0.47
## Dystopia...residual                                0.49
##                                            Standard.error.of.ladder.score
## Ladder.score                                                        -0.51
## Standard.error.of.ladder.score                                       1.00
## upperwhisker                                                        -0.48
## lowerwhisker                                                        -0.54
## Logged.GDP.per.capita                                               -0.58
## Social.support                                                      -0.48
## Healthy.life.expectancy                                             -0.62
## Freedom.to.make.life.choices                                        -0.29
## Generosity                                                           0.10
## Perceptions.of.corruption                                            0.30
## Explained.by..Log.GDP.per.capita                                    -0.58
## Explained.by..Social.support                                        -0.48
## Explained.by..Healthy.life.expectancy                               -0.62
## Explained.by..Freedom.to.make.life.choices                          -0.29
## Explained.by..Generosity                                             0.10
## Explained.by..Perceptions.of.corruption                             -0.30
## Dystopia...residual                                                 -0.01
##                                            upperwhisker lowerwhisker
## Ladder.score                                       1.00         1.00
## Standard.error.of.ladder.score                    -0.48        -0.54
## upperwhisker                                       1.00         1.00
## lowerwhisker                                       1.00         1.00
## Logged.GDP.per.capita                              0.78         0.79
## Social.support                                     0.84         0.84
## Healthy.life.expectancy                            0.74         0.76
## Freedom.to.make.life.choices                       0.66         0.66
## Generosity                                         0.04         0.04
## Perceptions.of.corruption                         -0.47        -0.47
## Explained.by..Log.GDP.per.capita                   0.78         0.79
## Explained.by..Social.support                       0.84         0.84
## Explained.by..Healthy.life.expectancy              0.74         0.76
## Explained.by..Freedom.to.make.life.choices         0.66         0.66
## Explained.by..Generosity                           0.04         0.03
## Explained.by..Perceptions.of.corruption            0.47         0.47
## Dystopia...residual                                0.50         0.48
##                                            Logged.GDP.per.capita Social.support
## Ladder.score                                                0.78           0.84
## Standard.error.of.ladder.score                             -0.58          -0.48
## upperwhisker                                                0.78           0.84
## lowerwhisker                                                0.79           0.84
## Logged.GDP.per.capita                                       1.00           0.74
## Social.support                                              0.74           1.00
## Healthy.life.expectancy                                     0.84           0.73
## Freedom.to.make.life.choices                                0.45           0.55
## Generosity                                                 -0.16           0.04
## Perceptions.of.corruption                                  -0.44          -0.28
## Explained.by..Log.GDP.per.capita                            1.00           0.74
## Explained.by..Social.support                                0.74           1.00
## Explained.by..Healthy.life.expectancy                       0.84           0.73
## Explained.by..Freedom.to.make.life.choices                  0.45           0.55
## Explained.by..Generosity                                   -0.16           0.04
## Explained.by..Perceptions.of.corruption                     0.44           0.28
## Dystopia...residual                                        -0.04           0.15
##                                            Healthy.life.expectancy
## Ladder.score                                                  0.75
## Standard.error.of.ladder.score                               -0.62
## upperwhisker                                                  0.74
## lowerwhisker                                                  0.76
## Logged.GDP.per.capita                                         0.84
## Social.support                                                0.73
## Healthy.life.expectancy                                       1.00
## Freedom.to.make.life.choices                                  0.42
## Generosity                                                   -0.14
## Perceptions.of.corruption                                    -0.40
## Explained.by..Log.GDP.per.capita                              0.84
## Explained.by..Social.support                                  0.73
## Explained.by..Healthy.life.expectancy                         1.00
## Explained.by..Freedom.to.make.life.choices                    0.42
## Explained.by..Generosity                                     -0.14
## Explained.by..Perceptions.of.corruption                       0.40
## Dystopia...residual                                          -0.01
##                                            Freedom.to.make.life.choices
## Ladder.score                                                       0.66
## Standard.error.of.ladder.score                                    -0.29
## upperwhisker                                                       0.66
## lowerwhisker                                                       0.66
## Logged.GDP.per.capita                                              0.45
## Social.support                                                     0.55
## Healthy.life.expectancy                                            0.42
## Freedom.to.make.life.choices                                       1.00
## Generosity                                                         0.16
## Perceptions.of.corruption                                         -0.38
## Explained.by..Log.GDP.per.capita                                   0.45
## Explained.by..Social.support                                       0.55
## Explained.by..Healthy.life.expectancy                              0.41
## Explained.by..Freedom.to.make.life.choices                         1.00
## Explained.by..Generosity                                           0.16
## Explained.by..Perceptions.of.corruption                            0.38
## Dystopia...residual                                                0.21
##                                            Generosity Perceptions.of.corruption
## Ladder.score                                     0.04                     -0.47
## Standard.error.of.ladder.score                   0.10                      0.30
## upperwhisker                                     0.04                     -0.47
## lowerwhisker                                     0.04                     -0.47
## Logged.GDP.per.capita                           -0.16                     -0.44
## Social.support                                   0.04                     -0.28
## Healthy.life.expectancy                         -0.14                     -0.40
## Freedom.to.make.life.choices                     0.16                     -0.38
## Generosity                                       1.00                     -0.12
## Perceptions.of.corruption                       -0.12                      1.00
## Explained.by..Log.GDP.per.capita                -0.16                     -0.44
## Explained.by..Social.support                     0.04                     -0.28
## Explained.by..Healthy.life.expectancy           -0.14                     -0.40
## Explained.by..Freedom.to.make.life.choices       0.16                     -0.38
## Explained.by..Generosity                         1.00                     -0.12
## Explained.by..Perceptions.of.corruption          0.12                     -1.00
## Dystopia...residual                              0.02                      0.00
##                                            Explained.by..Log.GDP.per.capita
## Ladder.score                                                           0.78
## Standard.error.of.ladder.score                                        -0.58
## upperwhisker                                                           0.78
## lowerwhisker                                                           0.79
## Logged.GDP.per.capita                                                  1.00
## Social.support                                                         0.74
## Healthy.life.expectancy                                                0.84
## Freedom.to.make.life.choices                                           0.45
## Generosity                                                            -0.16
## Perceptions.of.corruption                                             -0.44
## Explained.by..Log.GDP.per.capita                                       1.00
## Explained.by..Social.support                                           0.74
## Explained.by..Healthy.life.expectancy                                  0.84
## Explained.by..Freedom.to.make.life.choices                             0.45
## Explained.by..Generosity                                              -0.16
## Explained.by..Perceptions.of.corruption                                0.44
## Dystopia...residual                                                   -0.04
##                                            Explained.by..Social.support
## Ladder.score                                                       0.84
## Standard.error.of.ladder.score                                    -0.48
## upperwhisker                                                       0.84
## lowerwhisker                                                       0.84
## Logged.GDP.per.capita                                              0.74
## Social.support                                                     1.00
## Healthy.life.expectancy                                            0.73
## Freedom.to.make.life.choices                                       0.55
## Generosity                                                         0.04
## Perceptions.of.corruption                                         -0.28
## Explained.by..Log.GDP.per.capita                                   0.74
## Explained.by..Social.support                                       1.00
## Explained.by..Healthy.life.expectancy                              0.73
## Explained.by..Freedom.to.make.life.choices                         0.55
## Explained.by..Generosity                                           0.04
## Explained.by..Perceptions.of.corruption                            0.28
## Dystopia...residual                                                0.15
##                                            Explained.by..Healthy.life.expectancy
## Ladder.score                                                                0.75
## Standard.error.of.ladder.score                                             -0.62
## upperwhisker                                                                0.74
## lowerwhisker                                                                0.76
## Logged.GDP.per.capita                                                       0.84
## Social.support                                                              0.73
## Healthy.life.expectancy                                                     1.00
## Freedom.to.make.life.choices                                                0.41
## Generosity                                                                 -0.14
## Perceptions.of.corruption                                                  -0.40
## Explained.by..Log.GDP.per.capita                                            0.84
## Explained.by..Social.support                                                0.73
## Explained.by..Healthy.life.expectancy                                       1.00
## Explained.by..Freedom.to.make.life.choices                                  0.41
## Explained.by..Generosity                                                   -0.14
## Explained.by..Perceptions.of.corruption                                     0.40
## Dystopia...residual                                                        -0.01
##                                            Explained.by..Freedom.to.make.life.choices
## Ladder.score                                                                     0.66
## Standard.error.of.ladder.score                                                  -0.29
## upperwhisker                                                                     0.66
## lowerwhisker                                                                     0.66
## Logged.GDP.per.capita                                                            0.45
## Social.support                                                                   0.55
## Healthy.life.expectancy                                                          0.42
## Freedom.to.make.life.choices                                                     1.00
## Generosity                                                                       0.16
## Perceptions.of.corruption                                                       -0.38
## Explained.by..Log.GDP.per.capita                                                 0.45
## Explained.by..Social.support                                                     0.55
## Explained.by..Healthy.life.expectancy                                            0.41
## Explained.by..Freedom.to.make.life.choices                                       1.00
## Explained.by..Generosity                                                         0.16
## Explained.by..Perceptions.of.corruption                                          0.38
## Dystopia...residual                                                              0.21
##                                            Explained.by..Generosity
## Ladder.score                                                   0.04
## Standard.error.of.ladder.score                                 0.10
## upperwhisker                                                   0.04
## lowerwhisker                                                   0.03
## Logged.GDP.per.capita                                         -0.16
## Social.support                                                 0.04
## Healthy.life.expectancy                                       -0.14
## Freedom.to.make.life.choices                                   0.16
## Generosity                                                     1.00
## Perceptions.of.corruption                                     -0.12
## Explained.by..Log.GDP.per.capita                              -0.16
## Explained.by..Social.support                                   0.04
## Explained.by..Healthy.life.expectancy                         -0.14
## Explained.by..Freedom.to.make.life.choices                     0.16
## Explained.by..Generosity                                       1.00
## Explained.by..Perceptions.of.corruption                        0.12
## Dystopia...residual                                            0.02
##                                            Explained.by..Perceptions.of.corruption
## Ladder.score                                                                  0.47
## Standard.error.of.ladder.score                                               -0.30
## upperwhisker                                                                  0.47
## lowerwhisker                                                                  0.47
## Logged.GDP.per.capita                                                         0.44
## Social.support                                                                0.28
## Healthy.life.expectancy                                                       0.40
## Freedom.to.make.life.choices                                                  0.38
## Generosity                                                                    0.12
## Perceptions.of.corruption                                                    -1.00
## Explained.by..Log.GDP.per.capita                                              0.44
## Explained.by..Social.support                                                  0.28
## Explained.by..Healthy.life.expectancy                                         0.40
## Explained.by..Freedom.to.make.life.choices                                    0.38
## Explained.by..Generosity                                                      0.12
## Explained.by..Perceptions.of.corruption                                       1.00
## Dystopia...residual                                                           0.00
##                                            Dystopia...residual
## Ladder.score                                              0.49
## Standard.error.of.ladder.score                           -0.01
## upperwhisker                                              0.50
## lowerwhisker                                              0.48
## Logged.GDP.per.capita                                    -0.04
## Social.support                                            0.15
## Healthy.life.expectancy                                  -0.01
## Freedom.to.make.life.choices                              0.21
## Generosity                                                0.02
## Perceptions.of.corruption                                 0.00
## Explained.by..Log.GDP.per.capita                         -0.04
## Explained.by..Social.support                              0.15
## Explained.by..Healthy.life.expectancy                    -0.01
## Explained.by..Freedom.to.make.life.choices                0.21
## Explained.by..Generosity                                  0.02
## Explained.by..Perceptions.of.corruption                   0.00
## Dystopia...residual                                       1.00
corrplot(mat_corr,
         method = "square",
         type = "full",
         order = "hclust",
         tl.col = "black",
         tl.cex = 0.45)

Uji Bartlett & KMO

cortest.bartlett(mat_corr, n = n)
## $chisq
## [1] 15741.57
## 
## $p.value
## [1] 0
## 
## $df
## [1] 136
mat_corr = cor(data_num)
KMO(mat_corr)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = mat_corr)
## Overall MSA =  0.79
## MSA for each item = 
##                               Ladder.score 
##                                       0.85 
##             Standard.error.of.ladder.score 
##                                       0.83 
##                               upperwhisker 
##                                       0.84 
##                               lowerwhisker 
##                                       0.86 
##                      Logged.GDP.per.capita 
##                                       0.81 
##                             Social.support 
##                                       0.94 
##                    Healthy.life.expectancy 
##                                       0.77 
##               Freedom.to.make.life.choices 
##                                       0.84 
##                                 Generosity 
##                                       0.41 
##                  Perceptions.of.corruption 
##                                       0.70 
##           Explained.by..Log.GDP.per.capita 
##                                       0.88 
##               Explained.by..Social.support 
##                                       0.79 
##      Explained.by..Healthy.life.expectancy 
##                                       0.85 
## Explained.by..Freedom.to.make.life.choices 
##                                       0.75 
##                   Explained.by..Generosity 
##                                       0.54 
##    Explained.by..Perceptions.of.corruption 
##                                       0.68 
##                        Dystopia...residual 
##                                       0.27
data_num = data_num[, !names(data_num) %in% "Dystopia...residual"]

mat_corr = cor(data_num)
KMO(mat_corr)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = mat_corr)
## Overall MSA =  0.8
## MSA for each item = 
##                               Ladder.score 
##                                       0.82 
##             Standard.error.of.ladder.score 
##                                       0.83 
##                               upperwhisker 
##                                       0.84 
##                               lowerwhisker 
##                                       0.85 
##                      Logged.GDP.per.capita 
##                                       0.86 
##                             Social.support 
##                                       0.86 
##                    Healthy.life.expectancy 
##                                       0.83 
##               Freedom.to.make.life.choices 
##                                       0.78 
##                                 Generosity 
##                                       0.48 
##                  Perceptions.of.corruption 
##                                       0.67 
##           Explained.by..Log.GDP.per.capita 
##                                       0.86 
##               Explained.by..Social.support 
##                                       0.86 
##      Explained.by..Healthy.life.expectancy 
##                                       0.83 
## Explained.by..Freedom.to.make.life.choices 
##                                       0.78 
##                   Explained.by..Generosity 
##                                       0.48 
##    Explained.by..Perceptions.of.corruption 
##                                       0.67
data_num = data_num[, !names(data_num) %in% "Generosity"]

mat_corr = cor(data_num)
KMO(mat_corr)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = mat_corr)
## Overall MSA =  0.82
## MSA for each item = 
##                               Ladder.score 
##                                       0.82 
##             Standard.error.of.ladder.score 
##                                       0.83 
##                               upperwhisker 
##                                       0.85 
##                               lowerwhisker 
##                                       0.85 
##                      Logged.GDP.per.capita 
##                                       0.86 
##                             Social.support 
##                                       0.85 
##                    Healthy.life.expectancy 
##                                       0.83 
##               Freedom.to.make.life.choices 
##                                       0.78 
##                  Perceptions.of.corruption 
##                                       0.71 
##           Explained.by..Log.GDP.per.capita 
##                                       0.86 
##               Explained.by..Social.support 
##                                       0.85 
##      Explained.by..Healthy.life.expectancy 
##                                       0.83 
## Explained.by..Freedom.to.make.life.choices 
##                                       0.78 
##                   Explained.by..Generosity 
##                                       0.65 
##    Explained.by..Perceptions.of.corruption 
##                                       0.71

Partial Correlation

pcor(data_num)$estimate
##              [,1]          [,2]        [,3]        [,4]        [,5]
##  [1,]  1.00000000 -0.0229351958 -0.07815804 -0.03276391  0.23882495
##  [2,] -0.02293520  1.0000000000 -0.99847084  0.99844862 -0.11073399
##  [3,] -0.07815804 -0.9984708423  1.00000000  0.99384487 -0.09697078
##  [4,] -0.03276391  0.9984486216  0.99384487  1.00000000  0.12383876
##  [5,]  0.23882495 -0.1107339900 -0.09697078  0.12383876  1.00000000
##  [6,]  0.52579625 -0.0020732238  0.02688914  0.03152413  0.17463470
##  [7,]  0.11498923 -0.2621562762 -0.25497312  0.26840672  0.46231381
##  [8,]  0.40376064  0.0023164385  0.02435819  0.02024965 -0.05730766
##  [9,] -0.24265874  0.0363608932  0.02318217 -0.05004196 -0.16457508
## [10,]  0.23349479 -0.1258680786 -0.11234151  0.13866271 -0.99970721
## [11,]  0.52543048  0.0043330607  0.03325458  0.02510073  0.17602140
## [12,]  0.10417890 -0.4032387701 -0.39645515  0.40896753  0.47649268
## [13,]  0.40395714  0.0005247824  0.02258212  0.02205196 -0.05736289
## [14,]  0.03788261  0.0265771535  0.02951985 -0.02498450 -0.23208912
## [15,]  0.24223000 -0.0374376568 -0.02428096  0.05109528  0.16475266
##               [,6]        [,7]         [,8]        [,9]       [,10]
##  [1,]  0.525796247  0.11498923  0.403760639 -0.24265874  0.23349479
##  [2,] -0.002073224 -0.26215628  0.002316439  0.03636089 -0.12586808
##  [3,]  0.026889138 -0.25497312  0.024358189  0.02318217 -0.11234151
##  [4,]  0.031524135  0.26840672  0.020249647 -0.05004196  0.13866271
##  [5,]  0.174634702  0.46231381 -0.057307660 -0.16457508 -0.99970721
##  [6,]  1.000000000  0.18295559  0.054465727  0.32332794  0.18183066
##  [7,]  0.182955589  1.00000000 -0.085851675 -0.08720379  0.45215675
##  [8,]  0.054465727 -0.08585167  1.000000000 -0.11999317 -0.05397222
##  [9,]  0.323327941 -0.08720379 -0.119993166  1.00000000 -0.16964025
## [10,]  0.181830658  0.45215675 -0.053972220 -0.16964025  1.00000000
## [11,] -0.999974995  0.18487832  0.054510383  0.32387401  0.18336066
## [12,]  0.105882372 -0.96284858 -0.066733287 -0.02142352  0.46826711
## [13,]  0.053998955 -0.08622538 -0.999998254 -0.11963261 -0.05404741
## [14,]  0.159857779 -0.08826317  0.111919200 -0.18905851 -0.24849771
## [15,] -0.323147670  0.08699930  0.119957393  0.99999815  0.16982423
##              [,11]       [,12]         [,13]       [,14]       [,15]
##  [1,]  0.525430483  0.10417890  0.4039571442  0.03788261  0.24223000
##  [2,]  0.004333061 -0.40323877  0.0005247824  0.02657715 -0.03743766
##  [3,]  0.033254581 -0.39645515  0.0225821190  0.02951985 -0.02428096
##  [4,]  0.025100728  0.40896753  0.0220519571 -0.02498450  0.05109528
##  [5,]  0.176021401  0.47649268 -0.0573628878 -0.23208912  0.16475266
##  [6,] -0.999974995  0.10588237  0.0539989548  0.15985778 -0.32314767
##  [7,]  0.184878325 -0.96284858 -0.0862253761 -0.08826317  0.08699930
##  [8,]  0.054510383 -0.06673329 -0.9999982536  0.11191920  0.11995739
##  [9,]  0.323874013 -0.02142352 -0.1196326130 -0.18905851  0.99999815
## [10,]  0.183360656  0.46826711 -0.0540474114 -0.24849771  0.16982423
## [11,]  1.000000000  0.10806891  0.0540543717  0.16259064 -0.32369142
## [12,]  0.108068907  1.00000000 -0.0674440835  0.13650377  0.02074574
## [13,]  0.054054372 -0.06744408  1.0000000000  0.11226863  0.11959467
## [14,]  0.162590641  0.13650377  0.1122686250  1.00000000  0.19059414
## [15,] -0.323691416  0.02074574  0.1195946654  0.19059414  1.00000000

Standardisasi Data

data_scaled <- scale(data_num)
head(data_scaled)
##   Ladder.score Standard.error.of.ladder.score upperwhisker lowerwhisker
## 1     1.977143                     -1.2400045     1.967285     1.984519
## 2     1.786390                     -1.0225720     1.781644     1.789923
## 3     1.737389                     -0.6746801     1.744159     1.728201
## 4     1.687513                     -1.4139505     1.663833     1.708485
## 5     1.626263                     -1.5444099     1.596895     1.652763
## 6     1.619263                     -1.1965180     1.604035     1.632190
##   Logged.GDP.per.capita Social.support Healthy.life.expectancy
## 1             1.1047033       1.314600                1.075121
## 2             1.2451868       1.198856                1.092512
## 3             1.1906462       1.422628                1.231632
## 4             0.9782682       1.113977                1.344147
## 5             1.2286593       1.013666                1.144682
## 6             1.1799033       1.083112                1.249023
##   Freedom.to.make.life.choices Perceptions.of.corruption
## 1                    1.5370910                -3.0593720
## 2                    1.2970860                -2.9804333
## 3                    1.3148642                -0.3190715
## 4                    0.1859516                -0.0935324
## 5                    0.8792995                -1.9485917
## 6                    1.4215331                -2.9466024
##   Explained.by..Log.GDP.per.capita Explained.by..Social.support
## 1                        1.1039516                     1.313659
## 2                        1.2445146                     1.200600
## 3                        1.1915155                     1.420607
## 4                        0.9772145                     1.118097
## 5                        1.2283845                     1.017261
## 6                        1.1799939                     1.084485
##   Explained.by..Healthy.life.expectancy
## 1                              1.077429
## 2                              1.090193
## 3                              1.230597
## 4                              1.345472
## 5                              1.141249
## 6                              1.249742
##   Explained.by..Freedom.to.make.life.choices Explained.by..Generosity
## 1                                  1.5439724               -0.3038193
## 2                                  1.2900826                0.7752229
## 3                                  1.3168078                1.3279031
## 4                                  0.1876662               -0.3301374
## 5                                  0.8758413                1.3410621
## 6                                  1.4237088                0.9989268
##   Explained.by..Perceptions.of.corruption
## 1                              3.05901883
## 2                              2.98028408
## 3                              0.31904943
## 4                              0.09071865
## 5                              1.94885882
## 6                              2.94091670

PCA Manual

pca_cov <- cov(data_scaled)
pc <- eigen(pca_cov)

pc$values
##  [1] 9.230900e+00 1.782334e+00 1.469342e+00 8.372929e-01 6.255914e-01
##  [6] 4.366978e-01 3.167007e-01 3.011251e-01 5.742928e-06 4.510633e-06
## [11] 2.908879e-06 1.462823e-06 5.020987e-07 1.969544e-07 6.105159e-08
pc$vectors
##               [,1]        [,2]       [,3]         [,4]        [,5]        [,6]
##  [1,]  0.311414338 -0.03700666  0.1088730  0.035101137 -0.16778656  0.22964812
##  [2,] -0.204954000 -0.18297970  0.1659741 -0.023380846 -0.80540545 -0.48686588
##  [3,]  0.309399876 -0.04511375  0.1176289  0.034790543 -0.20343781  0.21461357
##  [4,]  0.313006843 -0.02919997  0.1002740  0.035310850 -0.13333275  0.24375091
##  [5,]  0.292765066  0.19177171 -0.1237022 -0.011346446 -0.04669026 -0.25006872
##  [6,]  0.287049505  0.10851543  0.2265742  0.193799846 -0.17301618  0.17015961
##  [7,]  0.285595274  0.22165382 -0.1307235  0.063962210  0.12551045 -0.38379549
##  [8,]  0.225447934 -0.35366818  0.3060861 -0.398182599  0.19321472 -0.16466440
##  [9,] -0.182102820  0.39980449  0.5164658 -0.006978190  0.10894851 -0.07591536
## [10,]  0.292751377  0.19177230 -0.1237285 -0.011303346 -0.04667551 -0.25024479
## [11,]  0.287071927  0.10848880  0.2264109  0.193638108 -0.17299083  0.17080876
## [12,]  0.285547601  0.22182825 -0.1308504  0.063941509  0.12554230 -0.38404404
## [13,]  0.225466605 -0.35363114  0.3061320 -0.398054795  0.19300615 -0.16483206
## [14,] -0.002127628 -0.44398016  0.2196359  0.771480391  0.26445436 -0.24673841
## [15,]  0.182101403 -0.39965767 -0.5166298  0.006784731 -0.10901024  0.07581136
##              [,7]        [,8]          [,9]         [,10]         [,11]
##  [1,]  0.22724120 -0.29895023  3.911162e-03 -0.0064389798  1.122534e-02
##  [2,] -0.03645674 -0.07929691 -9.698183e-04 -0.0033388110  1.489677e-03
##  [3,]  0.23023220 -0.30806218  8.819541e-03  0.0440540584 -2.056479e-02
##  [4,]  0.22409248 -0.28990949 -1.259071e-02 -0.0396637227  9.588166e-03
##  [5,]  0.39858064  0.37204649  1.117769e-02  0.0004095776 -1.381612e-04
##  [6,] -0.39669033  0.31732928 -1.038658e-01 -0.0637676907 -6.952733e-01
##  [7,] -0.26612526 -0.33785853 -1.091798e-01  0.1445666816 -3.512853e-02
##  [8,] -0.05445235  0.06662063 -6.899579e-01 -0.0452242544  1.121272e-01
##  [9,]  0.13262216 -0.07085599 -3.270192e-02  0.6863925764 -4.886730e-02
## [10,]  0.39885448  0.37185936 -1.104094e-02 -0.0002880759  8.404395e-05
## [11,] -0.39643746  0.31746004  1.032080e-01  0.0641389698  6.953671e-01
## [12,] -0.26627301 -0.33763081  1.090455e-01 -0.1447965623  3.565659e-02
## [13,] -0.05520296  0.06694565  6.899695e-01  0.0453066318 -1.120194e-01
## [14,]  0.16868806  0.01354585  5.968626e-05  0.0001647022  1.647631e-04
## [15,] -0.13247655  0.07033615 -3.286707e-02  0.6864071345 -4.901307e-02
##               [,12]         [,13]         [,14]         [,15]
##  [1,] -0.0218920131  2.529994e-02 -4.016909e-02  8.147086e-01
##  [2,]  0.0056156867  5.512322e-02 -5.304040e-04 -3.343414e-04
##  [3,] -0.0595364041 -6.992694e-01  2.705548e-02 -3.951439e-01
##  [4,]  0.0845903195  7.019181e-01  1.299111e-02 -4.202122e-01
##  [5,] -0.0284563255  1.081362e-02  7.056170e-01  3.368426e-02
##  [6,]  0.0396389458  5.734124e-03  2.411958e-03  1.065092e-02
##  [7,] -0.6775612288  7.682294e-02 -2.578730e-02 -1.981138e-02
##  [8,]  0.0921009126 -2.485890e-02  1.472019e-02  5.235385e-03
##  [9,]  0.1568112238  2.561978e-02  5.648939e-03  9.847325e-03
## [10,]  0.0282838134 -1.077184e-02 -7.055109e-01 -3.368360e-02
## [11,] -0.0395242040 -5.693020e-03 -2.681874e-03 -1.069778e-02
## [12,]  0.6773541336 -7.679719e-02  2.586719e-02  1.984933e-02
## [13,] -0.0920346865  2.492295e-02 -1.475384e-02 -5.216547e-03
## [14,]  0.0000617966 -5.334772e-05  8.629219e-05 -3.919250e-06
## [15,]  0.1568610422  2.571642e-02  5.575033e-03  9.876472e-03
sumvar <- sum(pc$values)
propvar <- (pc$values / sumvar) * 100

cumvar <- data.frame(
  eigen_value = pc$values,
  propvar = propvar,
  cum = cumsum(propvar)
)

cumvar
##     eigen_value      propvar       cum
## 1  9.230900e+00 6.153933e+01  61.53933
## 2  1.782334e+00 1.188223e+01  73.42156
## 3  1.469342e+00 9.795615e+00  83.21718
## 4  8.372929e-01 5.581953e+00  88.79913
## 5  6.255914e-01 4.170609e+00  92.96974
## 6  4.366978e-01 2.911319e+00  95.88106
## 7  3.167007e-01 2.111338e+00  97.99240
## 8  3.011251e-01 2.007501e+00  99.99990
## 9  5.742928e-06 3.828619e-05  99.99994
## 10 4.510633e-06 3.007089e-05  99.99997
## 11 2.908879e-06 1.939253e-05  99.99999
## 12 1.462823e-06 9.752157e-06  99.99999
## 13 5.020987e-07 3.347325e-06 100.00000
## 14 1.969544e-07 1.313029e-06 100.00000
## 15 6.105159e-08 4.070106e-07 100.00000
scores_manual <- as.matrix(data_scaled) %*% pc$vectors
head(scores_manual)
##       [,1]       [,2]      [,3]       [,4]       [,5]       [,6]        [,7]
## 1 5.924945 -2.2073707 -1.803664 -0.5602149 -0.4375955  1.0643820 -0.37367717
## 2 5.585480 -2.4316638 -1.752973  0.3971005 -0.2795842  0.5097201 -0.08652672
## 3 4.683336 -0.5340145  1.250480  0.8608631  0.1624367 -0.2462469  0.37021355
## 4 3.964661  1.2257097  0.174618  0.3905916  0.1143152  0.7421067  0.27890015
## 5 4.892086 -1.4734952 -1.050070  1.0815719  0.5155043  0.4005753  0.34303627
## 6 5.494840 -2.5223262 -1.748597  0.4296565  0.1485363  0.2477967 -0.20506027
##          [,8]         [,9]         [,10]         [,11]         [,12]
## 1 -0.11183362  0.004858199 -4.657647e-04 -0.0021067920  0.0013621970
## 2  0.03378413 -0.004933264  5.650661e-05  0.0014292183 -0.0005711069
## 3 -0.30856184  0.001186939  1.704007e-04 -0.0014256270 -0.0003673645
## 4 -0.83935060  0.002179032 -2.206526e-03  0.0025727946  0.0003626193
## 5 -0.13782675 -0.002146446  8.185646e-04  0.0023782849 -0.0017503496
## 6 -0.01553533  0.001867838 -3.743321e-03  0.0006583365 -0.0002907241
##           [,13]         [,14]         [,15]
## 1 -4.869255e-04  0.0002778996  7.113549e-05
## 2 -1.850627e-04  0.0004519019 -3.367879e-04
## 3  4.982133e-04 -0.0005671649  2.577038e-04
## 4  5.175780e-04  0.0007694942 -8.714844e-05
## 5 -8.140741e-05  0.0002080108 -8.012025e-05
## 6 -6.856012e-04 -0.0001673192 -2.835822e-05

PCA dengan psych

pc_psych <- principal(data_scaled, nfactors = 3, rotate = "none")
pc_psych
## Principal Components Analysis
## Call: principal(r = data_scaled, nfactors = 3, rotate = "none")
## Standardized loadings (pattern matrix) based upon correlation matrix
##                                              PC1   PC2   PC3   h2    u2 com
## Ladder.score                                0.95  0.05  0.13 0.92 0.085 1.0
## Standard.error.of.ladder.score             -0.62  0.24  0.20 0.49 0.512 1.5
## upperwhisker                                0.94  0.06  0.14 0.91 0.092 1.1
## lowerwhisker                                0.95  0.04  0.12 0.92 0.079 1.0
## Logged.GDP.per.capita                       0.89 -0.26 -0.15 0.88 0.121 1.2
## Social.support                              0.87 -0.14  0.27 0.86 0.143 1.3
## Healthy.life.expectancy                     0.87 -0.30 -0.16 0.87 0.134 1.3
## Freedom.to.make.life.choices                0.68  0.47  0.37 0.83 0.170 2.4
## Perceptions.of.corruption                  -0.55 -0.53  0.63 0.98 0.017 2.9
## Explained.by..Log.GDP.per.capita            0.89 -0.26 -0.15 0.88 0.121 1.2
## Explained.by..Social.support                0.87 -0.14  0.27 0.86 0.143 1.3
## Explained.by..Healthy.life.expectancy       0.87 -0.30 -0.16 0.87 0.134 1.3
## Explained.by..Freedom.to.make.life.choices  0.69  0.47  0.37 0.83 0.170 2.4
## Explained.by..Generosity                   -0.01  0.59  0.27 0.42 0.578 1.4
## Explained.by..Perceptions.of.corruption     0.55  0.53 -0.63 0.98 0.017 2.9
## 
##                        PC1  PC2  PC3
## SS loadings           9.23 1.78 1.47
## Proportion Var        0.62 0.12 0.10
## Cumulative Var        0.62 0.73 0.83
## Proportion Explained  0.74 0.14 0.12
## Cumulative Proportion 0.74 0.88 1.00
## 
## Mean item complexity =  1.6
## Test of the hypothesis that 3 components are sufficient.
## 
## The root mean square of the residuals (RMSR) is  0.04 
##  with the empirical chi square  47.01  with prob <  0.93 
## 
## Fit based upon off diagonal values = 1

PCA dengan FactoMineR

pca_result <- PCA(data_scaled,
                  scale.unit = FALSE,
                  ncp = 4,              # ambil 4 PC saja
                  graph = FALSE)

# Eigenvalues
pca_result$eig
##           eigenvalue percentage of variance cumulative percentage of variance
## comp 1  9.163026e+00           6.153933e+01                          61.53933
## comp 2  1.769229e+00           1.188223e+01                          73.42156
## comp 3  1.458538e+00           9.795615e+00                          83.21718
## comp 4  8.311364e-01           5.581953e+00                          88.79913
## comp 5  6.209914e-01           4.170609e+00                          92.96974
## comp 6  4.334868e-01           2.911319e+00                          95.88106
## comp 7  3.143721e-01           2.111338e+00                          97.99240
## comp 8  2.989110e-01           2.007501e+00                          99.99990
## comp 9  5.700701e-06           3.828619e-05                          99.99994
## comp 10 4.477467e-06           3.007089e-05                          99.99997
## comp 11 2.887490e-06           1.939253e-05                          99.99999
## comp 12 1.452067e-06           9.752157e-06                          99.99999
## comp 13 4.984068e-07           3.347325e-06                         100.00000
## comp 14 1.955062e-07           1.313029e-06                         100.00000
## comp 15 6.060268e-08           4.070106e-07                         100.00000
# Loadings (eigenvectors)
pca_result$var$coord
##                                                   Dim.1       Dim.2      Dim.3
## Ladder.score                                0.942666459  0.04922344  0.1314858
## Standard.error.of.ladder.score             -0.620405800  0.24338563  0.2004469
## upperwhisker                                0.936568583  0.06000687  0.1420603
## lowerwhisker                                0.947487048  0.03883957  0.1211009
## Logged.GDP.per.capita                       0.886214197 -0.25508009 -0.1493951
## Social.support                              0.868912914 -0.14433894  0.2736336
## Healthy.life.expectancy                     0.864510887 -0.29482699 -0.1578748
## Freedom.to.make.life.choices                0.682441942  0.47042243  0.3696600
## Perceptions.of.corruption                  -0.551234159 -0.53178941  0.6237355
## Explained.by..Log.GDP.per.capita            0.886172762 -0.25508088 -0.1494268
## Explained.by..Social.support                0.868980787 -0.14430352  0.2734363
## Explained.by..Healthy.life.expectancy       0.864366579 -0.29505901 -0.1580279
## Explained.by..Freedom.to.make.life.choices  0.682498459  0.47037315  0.3697155
## Explained.by..Generosity                   -0.006440435  0.59054852  0.2652542
## Explained.by..Perceptions.of.corruption     0.551229868  0.53159413 -0.6239336
##                                                   Dim.4
## Ladder.score                                0.032000541
## Standard.error.of.ladder.score             -0.021315541
## upperwhisker                                0.031717384
## lowerwhisker                                0.032191730
## Logged.GDP.per.capita                      -0.010344178
## Social.support                              0.176680888
## Healthy.life.expectancy                     0.058312224
## Freedom.to.make.life.choices               -0.363009860
## Perceptions.of.corruption                  -0.006361785
## Explained.by..Log.GDP.per.capita           -0.010304885
## Explained.by..Social.support                0.176533437
## Explained.by..Healthy.life.expectancy       0.058293351
## Explained.by..Freedom.to.make.life.choices -0.362893345
## Explained.by..Generosity                    0.703333067
## Explained.by..Perceptions.of.corruption     0.006185414
# Skor individu (koordinat observasi)
head(pca_result$ind$coord)
##      Dim.1      Dim.2     Dim.3      Dim.4
## 1 5.924945  2.2073707 -1.803664 -0.5602149
## 2 5.585480  2.4316638 -1.752973  0.3971005
## 3 4.683336  0.5340145  1.250480  0.8608631
## 4 3.964661 -1.2257097  0.174618  0.3905916
## 5 4.892086  1.4734952 -1.050070  1.0815719
## 6 5.494840  2.5223262 -1.748597  0.4296565

Visualisasi PCA

# scree plot
fviz_eig(pca_result,
         addlabels = TRUE,
         ncp = 4,
         barfill = "skyblue",
         barcolor = "darkblue",
         linecolor = "red")

var_names <- rownames(pca_result$var$coord)
alias_map <- setNames(paste0("X", seq_along(var_names)), var_names)

# Rename di semua komponen yang relevan
rownames(pca_result$var$coord)    <- alias_map[var_names]
rownames(pca_result$var$cor)      <- alias_map[var_names]
rownames(pca_result$var$cos2)     <- alias_map[var_names]
rownames(pca_result$var$contrib)  <- alias_map[var_names]
library(factoextra)
library(ggplot2)
library(ggrepel)

fviz_pca_biplot(pca_result,
                geom.ind   = "point",
                pointshape = 21,
                pointsize  = 2,
                fill.ind   = "white",
                col.ind    = "gray40",
                alpha.ind  = 0.7,
                col.var    = "#E63946",
                geom.var   = c("arrow", "text"),
                addEllipses = TRUE,
                ellipse.alpha = 0.05,
                label      = "var",
                repel      = TRUE
                ) +
  theme_minimal(base_size = 12) +
  theme(
    plot.title  = element_text(face = "bold", size = 14, hjust = 0.5),
    panel.grid.minor = element_blank(),
    panel.grid.major = element_line(color = "gray90", linetype = "dashed")
  ) +
  labs(title = "PCA Biplot")

# correlation circle
contrib_circle <- fviz_pca_var(pca_result, col.var = "contrib",
                               gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
                               repel = TRUE) +
  ggtitle("Kontribusi Variabel")
plot(contrib_circle)

# variable contribution
contrib_v_PC1 <- fviz_contrib(pca_result, choice = "var", axes = 1, top = 5) + ggtitle("PC1")
plot(contrib_v_PC1)

contrib_v_PC2 <- fviz_contrib(pca_result, choice = "var", axes = 2, top = 5) + ggtitle("PC2")
plot(contrib_v_PC2)

contrib_v_PC3 <- fviz_contrib(pca_result, choice = "var", axes = 3, top = 5) + ggtitle("PC3")
plot(contrib_v_PC3)

Factor Analysis Manual

varcov <- cov(data_scaled)
eig <- eigen(varcov)

L1 <- sqrt(eig$values[1]) * eig$vectors[,1]
L2 <- sqrt(eig$values[2]) * eig$vectors[,2]
L3 <- sqrt(eig$values[3]) * eig$vectors[,3]


L <- cbind(L1, L2, L3)

rownames(L) <- colnames(data_scaled)
colnames(L) <- c("Factor1","Factor2","Factor3")

L
##                                                 Factor1     Factor2    Factor3
## Ladder.score                                0.946151374 -0.04940541  0.1319719
## Standard.error.of.ladder.score             -0.622699360 -0.24428540  0.2011879
## upperwhisker                                0.940030955 -0.06022871  0.1425855
## lowerwhisker                                0.950989785 -0.03898316  0.1215485
## Logged.GDP.per.capita                       0.889490416  0.25602308 -0.1499474
## Social.support                              0.872125172  0.14487254  0.2746452
## Healthy.life.expectancy                     0.867706871  0.29591693 -0.1584584
## Freedom.to.make.life.choices                0.684964841 -0.47216152  0.3710266
## Perceptions.of.corruption                  -0.553272000  0.53375537  0.6260414
## Explained.by..Log.GDP.per.capita            0.889448828  0.25602388 -0.1499792
## Explained.by..Social.support                0.872193296  0.14483700  0.2744472
## Explained.by..Healthy.life.expectancy       0.867562030  0.29614980 -0.1586121
## Explained.by..Freedom.to.make.life.choices  0.685021567 -0.47211206  0.3710823
## Explained.by..Generosity                   -0.006464244 -0.59273170  0.2662348
## Explained.by..Perceptions.of.corruption     0.553267693 -0.53355937 -0.6262402
rot <- varimax(L)
rot$loadings
## 
## Loadings:
##                                            Factor1 Factor2 Factor3
## Ladder.score                                0.808  -0.472  -0.200 
## Standard.error.of.ladder.score             -0.664           0.209 
## upperwhisker                                0.797  -0.484  -0.196 
## lowerwhisker                                0.817  -0.460  -0.204 
## Logged.GDP.per.capita                       0.904          -0.241 
## Social.support                              0.835  -0.397         
## Healthy.life.expectancy                     0.904          -0.219 
## Freedom.to.make.life.choices                0.376  -0.813  -0.164 
## Perceptions.of.corruption                  -0.232   0.192   0.945 
## Explained.by..Log.GDP.per.capita            0.904          -0.241 
## Explained.by..Social.support                0.835  -0.397         
## Explained.by..Healthy.life.expectancy       0.904          -0.219 
## Explained.by..Freedom.to.make.life.choices  0.376  -0.813  -0.164 
## Explained.by..Generosity                   -0.289  -0.572  -0.109 
## Explained.by..Perceptions.of.corruption     0.232  -0.192  -0.945 
## 
##                Factor1 Factor2 Factor3
## SS loadings      7.533   2.721   2.229
## Proportion Var   0.502   0.181   0.149
## Cumulative Var   0.502   0.684   0.832

Factor Analysis dengan psych

fa_model <- principal(data_scaled, nfactors = 3, rotate = "varimax")
fa_model
## Principal Components Analysis
## Call: principal(r = data_scaled, nfactors = 3, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
##                                              RC1   RC2   RC3   h2    u2 com
## Ladder.score                                0.81  0.47  0.20 0.92 0.085 1.8
## Standard.error.of.ladder.score             -0.66  0.06 -0.21 0.49 0.512 1.2
## upperwhisker                                0.80  0.48  0.20 0.91 0.092 1.8
## lowerwhisker                                0.82  0.46  0.20 0.92 0.079 1.7
## Logged.GDP.per.capita                       0.90  0.07  0.24 0.88 0.121 1.2
## Social.support                              0.84  0.40 -0.04 0.86 0.143 1.4
## Healthy.life.expectancy                     0.90  0.02  0.22 0.87 0.134 1.1
## Freedom.to.make.life.choices                0.38  0.81  0.16 0.83 0.170 1.5
## Perceptions.of.corruption                  -0.23 -0.19 -0.94 0.98 0.017 1.2
## Explained.by..Log.GDP.per.capita            0.90  0.07  0.24 0.88 0.121 1.2
## Explained.by..Social.support                0.84  0.40 -0.04 0.86 0.143 1.4
## Explained.by..Healthy.life.expectancy       0.90  0.02  0.22 0.87 0.134 1.1
## Explained.by..Freedom.to.make.life.choices  0.38  0.81  0.16 0.83 0.170 1.5
## Explained.by..Generosity                   -0.29  0.57  0.11 0.42 0.578 1.6
## Explained.by..Perceptions.of.corruption     0.23  0.19  0.94 0.98 0.017 1.2
## 
##                        RC1  RC2  RC3
## SS loadings           7.53 2.72 2.23
## Proportion Var        0.50 0.18 0.15
## Cumulative Var        0.50 0.68 0.83
## Proportion Explained  0.60 0.22 0.18
## Cumulative Proportion 0.60 0.82 1.00
## 
## Mean item complexity =  1.4
## Test of the hypothesis that 3 components are sufficient.
## 
## The root mean square of the residuals (RMSR) is  0.04 
##  with the empirical chi square  47.01  with prob <  0.93 
## 
## Fit based upon off diagonal values = 1
fa_model$loadings
## 
## Loadings:
##                                            RC1    RC2    RC3   
## Ladder.score                                0.808  0.472  0.200
## Standard.error.of.ladder.score             -0.664        -0.209
## upperwhisker                                0.797  0.484  0.196
## lowerwhisker                                0.817  0.460  0.204
## Logged.GDP.per.capita                       0.904         0.241
## Social.support                              0.835  0.397       
## Healthy.life.expectancy                     0.904         0.219
## Freedom.to.make.life.choices                0.376  0.813  0.164
## Perceptions.of.corruption                  -0.232 -0.192 -0.945
## Explained.by..Log.GDP.per.capita            0.904         0.241
## Explained.by..Social.support                0.835  0.397       
## Explained.by..Healthy.life.expectancy       0.904         0.219
## Explained.by..Freedom.to.make.life.choices  0.376  0.813  0.164
## Explained.by..Generosity                   -0.289  0.572  0.109
## Explained.by..Perceptions.of.corruption     0.232  0.192  0.945
## 
##                  RC1   RC2   RC3
## SS loadings    7.533 2.721 2.229
## Proportion Var 0.502 0.181 0.149
## Cumulative Var 0.502 0.684 0.832
FA <- fa(data_scaled,
         covar = TRUE,
         nfactors = 3,
         rotate = "none",
         fm = "pa")

FA$loadings
## 
## Loadings:
##                                            PA1    PA2    PA3   
## Ladder.score                                0.944         0.137
## Standard.error.of.ladder.score             -0.586 -0.122  0.186
## upperwhisker                                0.937         0.149
## lowerwhisker                                0.950         0.125
## Logged.GDP.per.capita                       0.884  0.191 -0.236
## Social.support                              0.861  0.231  0.157
## Healthy.life.expectancy                     0.861  0.227 -0.264
## Freedom.to.make.life.choices                0.680 -0.304  0.545
## Perceptions.of.corruption                  -0.559  0.733  0.375
## Explained.by..Log.GDP.per.capita            0.884  0.191 -0.236
## Explained.by..Social.support                0.861  0.231  0.157
## Explained.by..Healthy.life.expectancy       0.861  0.227 -0.264
## Explained.by..Freedom.to.make.life.choices  0.680 -0.304  0.546
## Explained.by..Generosity                          -0.259  0.239
## Explained.by..Perceptions.of.corruption     0.559 -0.733 -0.375
## 
##                  PA1   PA2   PA3
## SS loadings    9.091 1.624 1.324
## Proportion Var 0.606 0.108 0.088
## Cumulative Var 0.606 0.714 0.803
FA$scores
##             PA1         PA2         PA3
## 1   -0.78525633 -4.33371639  2.08255903
## 2    0.23609892 -2.80364605 -0.63527101
## 3    4.82573023  2.17083166 -0.97318662
## 4    4.46560364  3.29680207 -3.08931031
## 5    0.64532062 -1.58587540 -0.11961562
## 6   -2.31364919 -4.95707604  2.69826722
## 7   -0.24104859 -2.59536042 -0.14903909
## 8    4.96418449  0.67313219 -4.05243703
## 9    2.56639237 -0.73881552 -1.44696839
## 10  -3.45257898 -5.12432717  3.19196760
## 11  -3.87709431 -4.06287013  3.75570496
## 12   6.67206347  2.61485532 -3.50871026
## 13   8.58033025  3.71370697 -5.62079686
## 14   7.75670769  2.74539480 -5.14105976
## 15   0.78665920  0.62334372 -0.44416475
## 16  -6.08202650 -5.96833248  5.46734381
## 17   2.36350310  1.03274745 -2.75125654
## 18   1.46161672  1.65091311  0.41291943
## 19   7.89754276  3.44198924 -5.35069021
## 20   1.53783444  2.04211783 -1.34634174
## 21   9.26258142  5.77287206 -8.64960322
## 22  -0.39000995 -0.18792611  1.84708679
## 23   4.83371958  2.74410812 -1.45397903
## 24   5.57833387  4.89339690 -3.48902788
## 25   4.26179500 -0.65284845 -3.65405534
## 26  -5.30519234 -4.95019125  5.67909300
## 27   5.68386119  4.40988192 -6.06122645
## 28   7.09675778  3.25148215 -3.79909774
## 29   3.38052969  3.67868811 -2.28972051
## 30   7.36318188  4.04071656 -3.76819763
## 31  -0.10150936 -1.83438069 -0.13186028
## 32   0.81437559  1.20050307 -1.76197657
## 33  -4.39546218 -2.20522975  4.61941455
## 34   0.51559512  0.53109365  1.93962631
## 35  -1.73139234 -0.67623405  2.79174503
## 36   1.22151390  0.49694215  0.98987195
## 37   1.54232499  1.04206937 -0.24909887
## 38  -7.74027434 -4.75521307  8.53232976
## 39  -2.45131626 -1.26563814  1.91709287
## 40  -4.09444674 -4.45339764  5.80698379
## 41   2.31830689  2.36932183 -1.41026278
## 42   0.01953982 -0.40778397  1.28337095
## 43  -2.44054268 -1.03649826  2.15703101
## 44  -6.39519791 -4.35171788  5.82315820
## 45  -6.17039978 -4.19513131  7.19036162
## 46  -2.35419999 -0.34145775  1.69953868
## 47   4.24057490  2.77630683 -3.70446256
## 48  -3.24226661 -0.58819994  2.81755998
## 49  -0.35626267 -0.52451371  1.67421985
## 50  -0.74344923 -2.40250396  3.04084184
## 51  -0.72363826  0.56235091  0.78165788
## 52  -0.96941541 -0.54591892  2.56331225
## 53   5.46895892  3.51657661 -2.36542113
## 54   0.07527028 -0.62185604  0.08031658
## 55   0.14915972  0.53172400 -0.57575830
## 56   0.74661270  1.35250839  0.33715344
## 57  -6.64348832 -4.00817892  4.67818911
## 58   6.22778336  5.86286442 -7.09311428
## 59   3.85253398  3.01825642 -2.92943729
## 60  -5.75739580 -2.80843334  5.66406901
## 61   1.35553906  1.97703783 -1.31077406
## 62   1.98764347  1.93841476  0.03666098
## 63  -5.04057253 -2.07142962  3.71940140
## 64  -5.17899038 -3.83960289  5.29687340
## 65   2.15193401  1.44116823 -1.59744439
## 66   4.63472381  3.54618786 -2.53165874
## 67   1.88737631  2.09485903 -1.10692912
## 68   6.27133951  4.63181671 -3.36452223
## 69  -5.99936106 -3.31126109  4.75524845
## 70  -5.13685521 -2.52873328  3.74138206
## 71   2.98673617  3.11214432 -1.37716904
## 72   6.73113373  5.69478031 -6.39560064
## 73   0.04826215 -0.57314044  0.40675989
## 74   4.08568417  3.40599227 -3.21668410
## 75  -1.59528980 -0.01295142  1.48348688
## 76  -9.12498551 -6.78499269  8.65209300
## 77  -3.92371872 -1.31003119  3.64141437
## 78   0.50628539  0.93437950 -1.47601716
## 79   6.27940696  3.95136493 -4.43933578
## 80  -4.91279827 -5.49838802  5.57262283
## 81  -3.86078326 -1.57913874  1.10404022
## 82  -0.58341021 -1.08309108 -2.83518373
## 83   2.91552087  2.98049924 -2.51736820
## 84  -0.60594202 -0.27586160  2.58268914
## 85   2.67487004  2.60334781 -0.97379728
## 86  -6.68039038 -4.72734651  5.14841922
## 87   2.13489173  2.19425015 -0.56799390
## 88  -3.26707677 -2.02294988  3.48707080
## 89   0.79179868 -0.82136093  1.50123053
## 90   3.07004337  2.13149560 -4.37736671
## 91  -1.21646434 -0.47484519  0.09172572
## 92   0.40685144  1.82883528 -1.12307069
## 93  -5.05420790 -3.79000578  4.32598724
## 94   3.19021424  2.62347999 -2.80232737
## 95   6.89959216  5.27373712 -4.68786611
## 96  -2.80507532 -1.08886538  1.56886172
## 97  -0.90708047 -1.88550516  1.37142575
## 98   2.31251278  3.11558385 -3.37937090
## 100 -2.64254309 -1.43371029  1.62974603
## 101 -3.05036065 -1.03045070  0.53171171
## 102 -6.38743380 -3.97092532  5.18059513
## 103  4.28528539  2.86903395 -5.28273055
## 104  3.62790910  2.36976819 -2.98224984
## 105  1.20776460  1.86940567 -2.22426424
## 106 -6.75093433 -2.95381475  3.64586225
## 107 -4.59664094 -2.50333288  3.67453346
## 108 -7.46066989 -4.50871104  4.42289033
## 109  4.92913455  3.21519810 -5.37286225
## 110 -1.66367993  0.86752283 -0.53310302
## 111 -3.55294115 -1.85612285  3.19878501
## 112  7.40115373  5.35153550 -5.40685293
## 113 -3.81890169 -1.04855889  1.04035604
## 114  2.67526606  1.83308609 -1.93807613
## 115  7.80535353  5.79792532 -6.49042811
## 116 -4.68689159 -4.31851631  2.31762378
## 117 -0.86581326 -0.40329929 -1.38913906
## 118 -6.29722148 -4.68389909  4.55616230
## 119  4.25618039  4.75251224 -6.63472538
## 120 -2.69511864 -1.56781213  2.48851393
## 121 -4.19732720 -2.84430031  0.48756387
## 122 -5.00556369 -2.65617151  1.05884952
## 123 -6.11240114 -4.47799166  5.06972968
## 124 -2.15997535 -1.43003650  2.24960847
## 125 -6.55081091 -3.58982159  3.41875513
## 126  7.03099999  4.58668516 -5.81822599
## 127 -0.94524758  0.12302109 -1.65384691
## 128 -5.74848386 -3.74624544  4.42780748
## 129  5.97958722  2.14325788 -4.52412404
## 130  2.46688298  3.10886349 -6.98770416
## 131  5.43244315  4.08176521 -7.05469821
## 132 -4.36516226 -2.04310025  2.30155412
## 133 -9.16341566 -5.54982770  6.22222360
## 134  0.86942327  0.61294705 -1.28054787
## 135 -7.10557100 -4.37061213  5.29082819
## 136 -4.20412327 -0.18176964 -1.07529102
## 137  3.97510610  4.71240350 -8.47938229