Load Library
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,
graph = FALSE,
ncp = ncol(data_num))
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
pca_result$svd$V
## [,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.0440540583 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.404394e-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.0218920130 2.529994e-02 -4.016909e-02 8.147086e-01
## [2,] 0.0056156868 5.512322e-02 -5.304040e-04 -3.343414e-04
## [3,] -0.0595364042 -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.0282838135 -1.077184e-02 -7.055109e-01 -3.368360e-02
## [11,] -0.0395242039 -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
head(pca_result$ind$coord)
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 Dim.6 Dim.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
## Dim.8 Dim.9 Dim.10 Dim.11 Dim.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
## Dim.13 Dim.14 Dim.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
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
R <- cor(data_scaled)
eig <- eigen(R)
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")
cat("Loading Manual (sebelum rotasi):\n")
## Loading Manual (sebelum rotasi):
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)
cat("Loading Manual (setelah rotasi):\n")
## Loading Manual (setelah rotasi):
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
Scree Plot
plot(eig$values, type = "b",
xlab = "Faktor",
ylab = "Eigenvalue",
main = "Scree Plot")
abline(h = 1, col = "red")

Faktor Analisis dengan Function
library(psych)
FA <- fa(data_scaled,
nfactors = 3,
rotate = "varimax",
fm = "pm")
FA
## Factor Analysis using method = minres
## Call: fa(r = data_scaled, nfactors = 3, rotate = "varimax", fm = "pm")
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 MR3 MR2 h2 u2 com
## Ladder.score 0.82 0.45 0.19 0.91 0.089 1.7
## Standard.error.of.ladder.score -0.60 -0.01 -0.17 0.39 0.607 1.2
## upperwhisker 0.81 0.46 0.19 0.90 0.099 1.7
## lowerwhisker 0.83 0.44 0.20 0.92 0.081 1.7
## Logged.GDP.per.capita 0.90 0.04 0.23 0.87 0.127 1.1
## Social.support 0.84 0.35 -0.01 0.82 0.180 1.3
## Healthy.life.expectancy 0.90 0.00 0.21 0.86 0.138 1.1
## Freedom.to.make.life.choices 0.38 0.83 0.15 0.85 0.149 1.5
## Perceptions.of.corruption -0.24 -0.20 -0.95 0.99 0.011 1.2
## Explained.by..Log.GDP.per.capita 0.90 0.04 0.23 0.87 0.127 1.1
## Explained.by..Social.support 0.84 0.35 -0.01 0.82 0.180 1.3
## Explained.by..Healthy.life.expectancy 0.90 0.00 0.21 0.86 0.138 1.1
## Explained.by..Freedom.to.make.life.choices 0.38 0.83 0.15 0.85 0.149 1.5
## Explained.by..Generosity -0.16 0.31 0.08 0.12 0.875 1.6
## Explained.by..Perceptions.of.corruption 0.24 0.20 0.95 0.99 0.010 1.2
##
## MR1 MR3 MR2
## SS loadings 7.46 2.40 2.18
## Proportion Var 0.50 0.16 0.15
## Cumulative Var 0.50 0.66 0.80
## Proportion Explained 0.62 0.20 0.18
## Cumulative Proportion 0.62 0.82 1.00
##
## Mean item complexity = 1.4
## Test of the hypothesis that 3 factors are sufficient.
##
## df null model = 105 with the objective function = 97.76 with Chi Square = 12626.78
## df of the model are 63 and the objective function was 76.01
##
## The root mean square of the residuals (RMSR) is 0.04
## The df corrected root mean square of the residuals is 0.06
##
## The harmonic n.obs is 136 with the empirical chi square 27.59 with prob < 1
## The total n.obs was 136 with Likelihood Chi Square = 9666.34 with prob < 0
##
## Tucker Lewis Index of factoring reliability = -0.298
## RMSEA index = 1.059 and the 90 % confidence intervals are 1.045 1.081
## BIC = 9356.84
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## MR1 MR3 MR2
## Correlation of (regression) scores with factors 0.99 0.95 1.00
## Multiple R square of scores with factors 0.97 0.91 0.99
## Minimum correlation of possible factor scores 0.94 0.82 0.98
FA$loadings
##
## Loadings:
## MR1 MR3 MR2
## Ladder.score 0.818 0.453 0.194
## Standard.error.of.ladder.score -0.602 -0.173
## upperwhisker 0.807 0.463 0.190
## lowerwhisker 0.827 0.442 0.197
## Logged.GDP.per.capita 0.904 0.232
## Social.support 0.836 0.346
## Healthy.life.expectancy 0.904 0.211
## Freedom.to.make.life.choices 0.378 0.828 0.151
## Perceptions.of.corruption -0.237 -0.200 -0.945
## Explained.by..Log.GDP.per.capita 0.904 0.232
## Explained.by..Social.support 0.836 0.346
## Explained.by..Healthy.life.expectancy 0.904 0.211
## Explained.by..Freedom.to.make.life.choices 0.378 0.828 0.151
## Explained.by..Generosity -0.158 0.306
## Explained.by..Perceptions.of.corruption 0.237 0.200 0.945
##
## MR1 MR3 MR2
## SS loadings 7.458 2.402 2.178
## Proportion Var 0.497 0.160 0.145
## Cumulative Var 0.497 0.657 0.803
FA$scores
## MR1 MR3 MR2
## 1 -2.92933367 3.27761764 2.1156866050
## 2 -0.90636630 0.73985383 2.6306770059
## 3 5.37414186 0.02667939 0.2044845820
## 4 5.90155465 -2.33684538 0.3055335511
## 5 -0.09943453 0.80556575 1.5074958339
## 6 -4.64679136 3.49950309 1.7951141883
## 7 -1.32117684 0.88231519 2.0851312263
## 8 5.35590152 -1.85398712 3.0666887806
## 9 2.19098447 0.04017199 2.0893235733
## 10 -5.81297914 3.56672529 1.3565030100
## 11 -5.82730687 3.43303330 0.1344275751
## 12 7.62198144 -1.60040321 1.7324403793
## 13 10.14420637 -3.12700983 2.5068189173
## 14 8.90735091 -2.62080092 2.8229431601
## 15 1.04083638 -0.34379301 -0.0310482980
## 16 -8.89001871 4.86185934 0.0892751408
## 17 2.98887412 -1.86811268 1.3747726575
## 18 1.94621740 0.17803556 -1.1191160302
## 19 9.37406295 -3.03679752 2.3974571726
## 20 2.47363977 -1.42049469 -0.4632718334
## 21 12.13545065 -6.27331973 2.7453980280
## 22 -0.73075706 1.47501342 -0.9565956501
## 23 5.70594647 -0.61554109 0.0351888692
## 24 7.64529231 -2.94394649 -0.4131454160
## 25 4.08835747 -1.22005645 3.7219264966
## 26 -7.78927038 4.88794767 -0.6348086440
## 27 7.95288925 -4.84121725 1.3779519370
## 28 8.31818436 -1.96014119 1.5332238296
## 29 4.97371008 -2.22758453 -0.7292697281
## 30 8.90004721 -2.16876153 0.9243310059
## 31 -0.86348056 0.62626215 1.4807267189
## 32 1.52991475 -1.67629023 0.2515565257
## 33 -5.61853354 3.18310663 -1.9588100946
## 34 0.36731498 1.57950421 -1.3146008850
## 35 -2.28692456 1.98323144 -1.4611020347
## 36 1.13588263 1.05882516 -0.5822390014
## 37 1.86196164 -0.08711061 -0.2568021351
## 38 -10.32553518 6.30001320 -3.0478708073
## 39 -3.04230517 1.24222558 -0.7016624705
## 40 -6.52795519 5.22494413 -0.7239542513
## 41 3.31666114 -1.33163982 -0.4580009541
## 42 -0.37568965 1.24385501 -0.3366360155
## 43 -2.96809512 1.34525536 -1.0331175874
## 44 -8.51665828 4.36223066 -1.5075328262
## 45 -8.47747355 5.51576423 -2.2859868585
## 46 -2.51637501 0.70542689 -1.2937364892
## 47 5.57588487 -2.71379467 0.9944923002
## 48 -3.59069889 1.41896981 -1.9767419863
## 49 -0.82159289 1.48669508 -0.5756730490
## 50 -2.21425547 3.27009680 0.1094643642
## 51 -0.52867527 0.15240068 -1.0506941186
## 52 -1.51603812 2.01310578 -1.2342864662
## 53 6.75796252 -1.46965221 0.0738805516
## 54 -0.21317097 0.35444609 0.4471755562
## 55 0.46517235 -0.64950644 -0.1061722218
## 56 1.19272777 -0.02094411 -1.0271627529
## 57 -8.39227313 3.17772348 -1.2640201836
## 58 9.24391704 -6.10926415 0.8968388456
## 59 5.21048511 -2.31297509 0.2675754394
## 60 -7.24752562 3.81190112 -2.4979834564
## 61 2.27051232 -1.43094617 -0.4462335702
## 62 2.59666956 -0.06875740 -0.9829609661
## 63 -5.97394255 2.14010253 -1.8196958856
## 64 -7.13457055 4.14626829 -1.2537976428
## 65 2.79393181 -1.16227082 0.3451966245
## 66 6.05860746 -1.92492357 -0.0898768174
## 67 2.76571332 -1.12013485 -0.5265872788
## 68 8.11886222 -2.47951919 -0.0443878087
## 69 -7.54087133 3.17478160 -1.6249801081
## 70 -6.25853759 2.32067535 -1.5152895818
## 71 4.22495791 -1.37349499 -0.8665964888
## 72 9.49559177 -5.28361906 0.8347038038
## 73 -0.27671848 0.59514295 0.2685788714
## 74 5.63021822 -2.63174727 0.1978490393
## 75 -1.66432867 0.66065207 -1.2314838105
## 76 -12.45812410 6.74816825 -1.8826308786
## 77 -4.64477338 2.15831005 -2.0351162952
## 78 1.10625269 -1.43907788 0.1501579726
## 79 8.01652013 -3.08281603 1.0246180653
## 80 -7.66944926 5.17236150 -0.0004981616
## 81 -4.28463950 0.18992912 -0.4654824446
## 82 -0.51877993 -2.11206535 2.2094005740
## 83 4.29248626 -2.29583727 -0.1658570918
## 84 -1.08625739 2.04311586 -1.3191427212
## 85 3.66234601 -0.93596518 -0.7814354280
## 86 -8.82021204 3.85614754 -0.9397435478
## 87 2.93185127 -0.62547568 -0.7812451845
## 88 -4.34452954 2.57400522 -1.2314963141
## 89 0.09053559 1.87762592 0.1046261409
## 90 4.36671979 -3.43029222 1.5469445318
## 91 -1.30083609 -0.16319380 -0.0175843393
## 92 1.34007410 -1.55933084 -0.7236397279
## 93 -6.83556999 3.36558988 -0.7811456527
## 94 4.43318234 -2.27765622 0.3096845702
## 95 9.17304586 -3.62296313 0.3302650675
## 96 -3.21178592 0.74887534 -0.8111929931
## 97 -1.84635712 1.60566576 0.4710928007
## 98 3.96402642 -3.28644508 -0.0106161229
## 100 -3.23320086 1.00009453 -0.4882312142
## 101 -3.23117258 -0.22490541 -0.3744014895
## 102 -8.24283013 3.66549767 -1.4351568666
## 103 5.91409129 -4.05053561 1.7858705808
## 104 4.73687773 -2.16426914 0.7461977383
## 105 2.25069594 -2.20012553 0.0488891946
## 106 -7.86015596 1.83909210 -1.5691665561
## 107 -5.77054110 2.44298821 -1.2759665857
## 108 -9.29799490 2.87198755 -0.9323498202
## 109 6.64727728 -4.04493565 1.7579141647
## 110 -1.00603495 -1.41030429 -0.8839387568
## 111 -4.48078243 2.15651509 -1.2661735862
## 112 9.77960805 -4.07313946 0.7511374098
## 113 -3.99984865 -0.07615891 -0.8766227925
## 114 3.47918805 -1.41658347 0.3842271622
## 115 10.51004686 -5.02116744 1.0941329162
## 116 -6.40999807 2.04815275 0.8265645201
## 117 -0.71181420 -1.30073620 0.8078151601
## 118 -8.35866318 3.47964307 -0.5693896218
## 119 6.93428511 -5.98066181 0.9901770247
## 120 -3.47605642 1.75379790 -0.8823971063
## 121 -5.02924683 0.08227319 0.7618084418
## 122 -5.76304247 0.18459783 0.1023929148
## 123 -8.19228775 3.88947195 -0.9424941948
## 124 -2.91480805 1.68939025 -0.6441375078
## 125 -7.92372609 1.98042789 -0.8823749878
## 126 9.18162463 -4.23330648 1.5015765384
## 127 -0.50978195 -1.76814950 0.5099884479
## 128 -7.45412103 3.17552024 -1.0357824694
## 129 6.96813445 -2.50599959 2.4690266732
## 130 4.69463860 -6.22961734 1.9634277171
## 131 7.75398340 -5.62664025 2.0826590218
## 132 -5.13157381 1.19048375 -0.8765113724
## 133 -11.55396180 4.19199959 -1.5710071689
## 134 1.24366510 -1.01099741 0.4700306574
## 135 -9.06711448 3.66698032 -1.4058564573
## 136 -3.61144930 -2.34002690 -0.5473028922
## 137 6.97344545 -7.60185377 1.9285623806
load <- as.matrix(FA$loadings)
load_max <- load
for(i in 1:nrow(load)){
max_col <- which.max(abs(load[i,]))
load_max[i, -max_col] <- 0
}
fa.diagram(load_max,
simple = TRUE,
cex = 0.8,
marg = c(5, 12, 4, 2),
main = "Diagram Factor Analysis")
