H_2015 <- read.csv("2015.csv")
H_2016 <- read.csv("2016.csv")
H_2017 <- read.csv("2017.csv")
H_2018 <- read.csv("2018.csv")
H_2019 <- read.csv("2019.csv")
colnames(H_2018)[2] <- "Country"
colnames(H_2019)[2] <- "Country"
years <- c("H_2015", "H_2016", "H_2017", "H_2018", "H_2019")
for(i in 1:5){
cyr <- get(years[i])
df <- order(cyr$Country)
cyr <- cyr[df, ]
assign(years[i], cyr)
}
missing_list <- paste("missing_", 2015:2019, sep = "")
for(i in 1:5){
temp <- 0
for(j in 1:4){
df <- years[i] == years
yr <- years[!df]
cyr <- get(years[i])
cyr2 <- get(yr[j])
missing <- is.element(cyr$Country,cyr2$Country)
if(sum(!missing != 0)){
misel <- cyr$Country[!missing]
if(temp[1] == 0){
temp <- misel
}
else{
temp <- c(temp, misel)
}
}}
assign(missing_list[i], unique(temp))}
for(i in 1:5){
cyr <- get(years[i])
missing <- is.element(cyr$Country, get(missing_list[i]))
cyr <- cyr[!missing,]
assign(years[i], cyr)
}
for(i in 1:3){
cyr <- get(years[i])
colnames(cyr)[4] <- "Score"
assign(years[i], cyr)
}
H_years <- data.frame(H_2015$Country)
a <- 2
for(i in 1:5){
cyr <- get(years[i])
H_years[,a] <- cyr$Score
a <- a+1
}
colnames(H_years) <- c("Country", 2015, 2016, 2017, 2018, 2019)
happiness_changes <- data.frame(H_2015$Country)
for(i in 2:5){
happiness_changes[,i] <- (H_years[,i] - H_years[,i+1])
}
colnames(happiness_changes) <- c("Country", "15 - 16", "16 - 17", "17 - 18", "18 - 19")
Full_H_Score
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.4
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
rmr <- c(1,2,4)
H_full <- H_2015[,rmr]
for(i in 2:5){
cyr <- get(years[i])
H_full[,2+i] <- cyr %>% pull(Score)
}
colnames(H_full)[3:7] <- c("2015", "2016", "2017", "2018", "2019")
Scores without Dytopia for 2015-2017
H_diff <- H_full
for(i in 1:3){
cyr <- get(years[i])
cyr <- (cyr %>% pull(Dystopia.Residual))
H_diff[,i+2] <- (H_diff[, i+2] - cyr)
}
H_diff <- H_diff[,1:5]
t-student all values 2015
library(teigen)
data <- H_2015[,6:11]
t.out <- teigen(x=data,Gs=1:20,models="UUUU")
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0 secs | Approx. remaining: 0.6 secs | 5% completeTime taken: 0.1 secs | Approx. remaining: 0.6 secs | 10% completeTime taken: 0.1 secs | Approx. remaining: 0.6 secs | 15% completeTime taken: 0.3 secs | Approx. remaining: 1.2 secs | 20% completeTime taken: 0.4 secs | Approx. remaining: 1.3 secs | 25% completeTime taken: 0.5 secs | Approx. remaining: 1.2 secs | 30% completeTime taken: 0.5 secs | Approx. remaining: 1 secs | 35% completeTime taken: 0.5 secs | Approx. remaining: 0.8 secs | 40% completeTime taken: 0.5 secs | Approx. remaining: 0.7 secs | 45% completeTime taken: 0.5 secs | Approx. remaining: 0.5 secs | 50% completeTime taken: 0.5 secs | Approx. remaining: 0.4 secs | 55% completeTime taken: 0.5 secs | Approx. remaining: 0.4 secs | 60% completeTime taken: 0.5 secs | Approx. remaining: 0.3 secs | 65% completeTime taken: 0.5 secs | Approx. remaining: 0.2 secs | 70% completeTime taken: 0.5 secs | Approx. remaining: 0.2 secs | 75% completeTime taken: 0.5 secs | Approx. remaining: 0.1 secs | 80% completeTime taken: 0.5 secs | Approx. remaining: 0.1 secs | 85% completeTime taken: 0.5 secs | Approx. remaining: 0.1 secs | 90% completeTime taken: 0.5 secs | Approx. remaining: 0 secs | 95% completeTime taken: 0.5 secs | Approx. remaining: 0 secs | 100% complete
t.out
## BIC and ICL select the same model and groups.
## The best model (BIC of -2113.28, ICL of -2130.6157) is UUUU with G=2
t.out$allbic
## G=1 G=2 G=3 G=4 G=5 G=6 G=7 G=8
## -2159.758 -2113.284 -2125.745 -2183.225 -2256.903 -2370.148 -Inf -Inf
## G=9 G=10 G=11 G=12 G=13 G=14 G=15 G=16
## -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf
## G=17 G=18 G=19 G=20
## -Inf -Inf -Inf -Inf
t.out$parameters$df
## [1] 11.11921 42.53186
Classification for 2 = 2015
Cl_2015 <- H_full[,1:3]
Cl_2015$Two_All <- t.out$classification
Classification for 3 = 2015
t.out <- teigen(x=data,Gs=3,models="UUUU")
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0 secs | Approx. remaining: 0 secs | 100% complete
t.out$parameters$df
## [1] 5.809493 3.836335 66.670853
Cl_2015$Three_All <- t.out$classification
MixGHD
library(MixGHD)
## Warning: package 'MixGHD' was built under R version 4.0.5
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
MGHD
mixg <- MGHD(data, G = 1:20, scale = FALSE)
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Error in cov.wt(x, wt = abc[, 2] * weights, center = mu.new, method = "ML") :
## weights must be non-negative and not all zero
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Error in if (sum(x) == 0) x = rep(1, length(x)) :
## missing value where TRUE/FALSE needed
## Error in w[, k] : incorrect number of dimensions
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Error in cov.wt(x, wt = abc[, 2] * weights, center = mu.new, method = "ML") :
## weights must be non-negative and not all zero
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## Warning in log(det(sigma)): NaNs produced
## The best model (AIC) for the range of components used is G = 16.
## The AIC for this model is 2246.496.
Cl_2015$Mix_G <- mixg@map
rmr <- order(Cl_2015$Mix_G)
Cl_2015[rmr, c(1, 2,3,6)]
## Country Region 2015 Mix_G
## 16 Brazil Latin America and Caribbean 6.983 1
## 153 Afghanistan Southern Asia 3.575 2
## 95 Albania Central and Eastern Europe 4.959 2
## 109 Bangladesh Southern Asia 4.694 2
## 155 Benin Sub-Saharan Africa 3.340 2
## 51 Bolivia Latin America and Caribbean 5.890 2
## 152 Burkina Faso Sub-Saharan Africa 3.587 2
## 145 Cambodia Southeastern Asia 3.819 2
## 133 Cameroon Sub-Saharan Africa 4.252 2
## 149 Chad Sub-Saharan Africa 3.667 2
## 139 Congo (Brazzaville) Sub-Saharan Africa 3.989 2
## 120 Congo (Kinshasa) Sub-Saharan Africa 4.517 2
## 135 Egypt Middle East and Northern Africa 4.194 2
## 42 El Salvador Latin America and Caribbean 6.130 2
## 122 Ethiopia Sub-Saharan Africa 4.512 2
## 143 Gabon Sub-Saharan Africa 3.896 2
## 114 Ghana Sub-Saharan Africa 4.633 2
## 43 Guatemala Latin America and Caribbean 6.123 2
## 150 Guinea Sub-Saharan Africa 3.656 2
## 105 Honduras Latin America and Caribbean 4.788 2
## 117 India Southern Asia 4.565 2
## 110 Iran Middle East and Northern Africa 4.686 2
## 151 Ivory Coast Sub-Saharan Africa 3.655 2
## 54 Kazakhstan Central and Eastern Europe 5.855 2
## 125 Kenya Sub-Saharan Africa 4.419 2
## 116 Liberia Sub-Saharan Africa 4.571 2
## 147 Madagascar Sub-Saharan Africa 3.681 2
## 138 Mali Sub-Saharan Africa 3.995 2
## 92 Morocco Middle East and Northern Africa 5.013 2
## 121 Nepal Southern Asia 4.514 2
## 144 Niger Sub-Saharan Africa 3.845 2
## 78 Nigeria Sub-Saharan Africa 5.268 2
## 108 Palestinian Territories Middle East and Northern Africa 4.715 2
## 90 Philippines Southeastern Asia 5.073 2
## 142 Senegal Sub-Saharan Africa 3.904 2
## 123 Sierra Leone Sub-Saharan Africa 4.507 2
## 113 South Africa Sub-Saharan Africa 4.642 2
## 106 Tajikistan Central and Eastern Europe 4.786 2
## 146 Tanzania Sub-Saharan Africa 3.781 2
## 158 Togo Sub-Saharan Africa 2.839 2
## 107 Tunisia Middle East and Northern Africa 4.739 2
## 75 Vietnam Southeastern Asia 5.360 2
## 136 Yemen Middle East and Northern Africa 4.077 2
## 85 Zambia Sub-Saharan Africa 5.129 2
## 115 Zimbabwe Sub-Saharan Africa 4.610 2
## 29 France Western Europe 6.575 3
## 157 Burundi Sub-Saharan Africa 2.905 4
## 130 Georgia Central and Eastern Europe 4.297 5
## 70 Turkmenistan Central and Eastern Europe 5.548 6
## 39 Kuwait Middle East and Northern Africa 6.295 7
## 64 Russia Central and Eastern Europe 5.716 8
## 128 Botswana Sub-Saharan Africa 4.332 9
## 112 Iraq Middle East and Northern Africa 4.677 10
## 28 Qatar Middle East and Northern Africa 6.611 11
## 68 Algeria Middle East and Northern Africa 5.605 12
## 30 Argentina Latin America and Caribbean 6.574 12
## 127 Armenia Central and Eastern Europe 4.350 12
## 10 Australia Australia and New Zealand 7.284 12
## 13 Austria Western Europe 7.200 12
## 80 Azerbaijan Central and Eastern Europe 5.212 12
## 49 Bahrain Middle East and Northern Africa 5.960 12
## 59 Belarus Central and Eastern Europe 5.813 12
## 19 Belgium Western Europe 6.937 12
## 79 Bhutan Southern Asia 5.253 12
## 96 Bosnia and Herzegovina Central and Eastern Europe 4.949 12
## 134 Bulgaria Central and Eastern Europe 4.218 12
## 5 Canada North America 7.427 12
## 27 Chile Latin America and Caribbean 6.670 12
## 84 China Eastern Asia 5.140 12
## 33 Colombia Latin America and Caribbean 6.477 12
## 12 Costa Rica Latin America and Caribbean 7.226 12
## 62 Croatia Central and Eastern Europe 5.759 12
## 67 Cyprus Western Europe 5.689 12
## 31 Czech Republic Central and Eastern Europe 6.505 12
## 3 Denmark Western Europe 7.527 12
## 98 Dominican Republic Latin America and Caribbean 4.885 12
## 48 Ecuador Latin America and Caribbean 5.975 12
## 73 Estonia Central and Eastern Europe 5.429 12
## 6 Finland Western Europe 7.406 12
## 26 Germany Western Europe 6.750 12
## 102 Greece Western Europe 4.857 12
## 119 Haiti Latin America and Caribbean 4.518 12
## 104 Hungary Central and Eastern Europe 4.800 12
## 74 Indonesia Southeastern Asia 5.399 12
## 18 Ireland Western Europe 6.940 12
## 11 Israel Middle East and Northern Africa 7.278 12
## 50 Italy Western Europe 5.948 12
## 65 Jamaica Latin America and Caribbean 5.709 12
## 46 Japan Eastern Asia 5.987 12
## 82 Jordan Middle East and Northern Africa 5.192 12
## 69 Kosovo Central and Eastern Europe 5.589 12
## 89 Latvia Central and Eastern Europe 5.098 12
## 103 Lebanon Middle East and Northern Africa 4.839 12
## 63 Libya Middle East and Northern Africa 5.754 12
## 56 Lithuania Central and Eastern Europe 5.833 12
## 17 Luxembourg Western Europe 6.946 12
## 61 Malaysia Southeastern Asia 5.770 12
## 37 Malta Western Europe 6.302 12
## 124 Mauritania Sub-Saharan Africa 4.436 12
## 71 Mauritius Sub-Saharan Africa 5.477 12
## 14 Mexico Latin America and Caribbean 7.187 12
## 100 Mongolia Eastern Asia 4.874 12
## 83 Montenegro Central and Eastern Europe 5.192 12
## 129 Myanmar Southeastern Asia 4.307 12
## 7 Netherlands Western Europe 7.378 12
## 9 New Zealand Australia and New Zealand 7.286 12
## 57 Nicaragua Latin America and Caribbean 5.828 12
## 4 Norway Western Europe 7.522 12
## 81 Pakistan Southern Asia 5.194 12
## 25 Panama Latin America and Caribbean 6.786 12
## 53 Paraguay Latin America and Caribbean 5.878 12
## 58 Peru Latin America and Caribbean 5.824 12
## 60 Poland Central and Eastern Europe 5.791 12
## 88 Portugal Western Europe 5.102 12
## 86 Romania Central and Eastern Europe 5.124 12
## 154 Rwanda Sub-Saharan Africa 3.465 12
## 35 Saudi Arabia Middle East and Northern Africa 6.411 12
## 87 Serbia Central and Eastern Europe 5.123 12
## 24 Singapore Southeastern Asia 6.798 12
## 45 Slovakia Central and Eastern Europe 5.995 12
## 55 Slovenia Central and Eastern Europe 5.848 12
## 47 South Korea Eastern Asia 5.984 12
## 36 Spain Western Europe 6.329 12
## 132 Sri Lanka Southern Asia 4.271 12
## 8 Sweden Western Europe 7.364 12
## 1 Switzerland Western Europe 7.587 12
## 156 Syria Middle East and Northern Africa 3.006 12
## 34 Thailand Southeastern Asia 6.455 12
## 76 Turkey Middle East and Northern Africa 5.332 12
## 141 Uganda Sub-Saharan Africa 3.931 12
## 111 Ukraine Central and Eastern Europe 4.681 12
## 20 United Arab Emirates Middle East and Northern Africa 6.901 12
## 21 United Kingdom Western Europe 6.867 12
## 15 United States North America 7.119 12
## 32 Uruguay Latin America and Caribbean 6.485 12
## 44 Uzbekistan Central and Eastern Europe 6.003 12
## 23 Venezuela Latin America and Caribbean 6.810 12
## 77 Kyrgyzstan Central and Eastern Europe 5.286 13
## 52 Moldova Central and Eastern Europe 5.889 14
## 2 Iceland Western Europe 7.561 15
## 131 Malawi Sub-Saharan Africa 4.292 16
t.out <- teigen(x=data,Gs=6,models="UUUU")
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0.1 secs | Approx. remaining: 0 secs | 100% complete
t.out$parameters$df
## [1] 108.092006 147.677754 74.127728 194.653092 3.932925 7.861088
Cl_2015$Six_All <- t.out$classification
rmr <- order(Cl_2015$Six_All)
Cl_2015[rmr, c(1, 2,3,7)]
## Country Region 2015 Six_All
## 95 Albania Central and Eastern Europe 4.959 1
## 68 Algeria Middle East and Northern Africa 5.605 1
## 30 Argentina Latin America and Caribbean 6.574 1
## 127 Armenia Central and Eastern Europe 4.350 1
## 80 Azerbaijan Central and Eastern Europe 5.212 1
## 59 Belarus Central and Eastern Europe 5.813 1
## 96 Bosnia and Herzegovina Central and Eastern Europe 4.949 1
## 16 Brazil Latin America and Caribbean 6.983 1
## 134 Bulgaria Central and Eastern Europe 4.218 1
## 84 China Eastern Asia 5.140 1
## 62 Croatia Central and Eastern Europe 5.759 1
## 31 Czech Republic Central and Eastern Europe 6.505 1
## 48 Ecuador Latin America and Caribbean 5.975 1
## 135 Egypt Middle East and Northern Africa 4.194 1
## 42 El Salvador Latin America and Caribbean 6.130 1
## 73 Estonia Central and Eastern Europe 5.429 1
## 102 Greece Western Europe 4.857 1
## 104 Hungary Central and Eastern Europe 4.800 1
## 112 Iraq Middle East and Northern Africa 4.677 1
## 82 Jordan Middle East and Northern Africa 5.192 1
## 54 Kazakhstan Central and Eastern Europe 5.855 1
## 69 Kosovo Central and Eastern Europe 5.589 1
## 89 Latvia Central and Eastern Europe 5.098 1
## 103 Lebanon Middle East and Northern Africa 4.839 1
## 63 Libya Middle East and Northern Africa 5.754 1
## 56 Lithuania Central and Eastern Europe 5.833 1
## 14 Mexico Latin America and Caribbean 7.187 1
## 83 Montenegro Central and Eastern Europe 5.192 1
## 108 Palestinian Territories Middle East and Northern Africa 4.715 1
## 58 Peru Latin America and Caribbean 5.824 1
## 88 Portugal Western Europe 5.102 1
## 86 Romania Central and Eastern Europe 5.124 1
## 64 Russia Central and Eastern Europe 5.716 1
## 87 Serbia Central and Eastern Europe 5.123 1
## 45 Slovakia Central and Eastern Europe 5.995 1
## 107 Tunisia Middle East and Northern Africa 4.739 1
## 76 Turkey Middle East and Northern Africa 5.332 1
## 111 Ukraine Central and Eastern Europe 4.681 1
## 23 Venezuela Latin America and Caribbean 6.810 1
## 75 Vietnam Southeastern Asia 5.360 1
## 153 Afghanistan Southern Asia 3.575 2
## 155 Benin Sub-Saharan Africa 3.340 2
## 130 Georgia Central and Eastern Europe 4.297 2
## 150 Guinea Sub-Saharan Africa 3.656 2
## 119 Haiti Latin America and Caribbean 4.518 2
## 117 India Southern Asia 4.565 2
## 110 Iran Middle East and Northern Africa 4.686 2
## 131 Malawi Sub-Saharan Africa 4.292 2
## 81 Pakistan Southern Asia 5.194 2
## 156 Syria Middle East and Northern Africa 3.006 2
## 158 Togo Sub-Saharan Africa 2.839 2
## 79 Bhutan Southern Asia 5.253 3
## 51 Bolivia Latin America and Caribbean 5.890 3
## 145 Cambodia Southeastern Asia 3.819 3
## 33 Colombia Latin America and Caribbean 6.477 3
## 98 Dominican Republic Latin America and Caribbean 4.885 3
## 43 Guatemala Latin America and Caribbean 6.123 3
## 74 Indonesia Southeastern Asia 5.399 3
## 65 Jamaica Latin America and Caribbean 5.709 3
## 125 Kenya Sub-Saharan Africa 4.419 3
## 61 Malaysia Southeastern Asia 5.770 3
## 71 Mauritius Sub-Saharan Africa 5.477 3
## 100 Mongolia Eastern Asia 4.874 3
## 129 Myanmar Southeastern Asia 4.307 3
## 25 Panama Latin America and Caribbean 6.786 3
## 53 Paraguay Latin America and Caribbean 5.878 3
## 90 Philippines Southeastern Asia 5.073 3
## 60 Poland Central and Eastern Europe 5.791 3
## 55 Slovenia Central and Eastern Europe 5.848 3
## 132 Sri Lanka Southern Asia 4.271 3
## 34 Thailand Southeastern Asia 6.455 3
## 49 Bahrain Middle East and Northern Africa 5.960 4
## 27 Chile Latin America and Caribbean 6.670 4
## 12 Costa Rica Latin America and Caribbean 7.226 4
## 67 Cyprus Western Europe 5.689 4
## 29 France Western Europe 6.575 4
## 11 Israel Middle East and Northern Africa 7.278 4
## 50 Italy Western Europe 5.948 4
## 46 Japan Eastern Asia 5.987 4
## 39 Kuwait Middle East and Northern Africa 6.295 4
## 57 Nicaragua Latin America and Caribbean 5.828 4
## 35 Saudi Arabia Middle East and Northern Africa 6.411 4
## 47 South Korea Eastern Asia 5.984 4
## 36 Spain Western Europe 6.329 4
## 70 Turkmenistan Central and Eastern Europe 5.548 4
## 32 Uruguay Latin America and Caribbean 6.485 4
## 44 Uzbekistan Central and Eastern Europe 6.003 4
## 10 Australia Australia and New Zealand 7.284 5
## 13 Austria Western Europe 7.200 5
## 19 Belgium Western Europe 6.937 5
## 5 Canada North America 7.427 5
## 3 Denmark Western Europe 7.527 5
## 6 Finland Western Europe 7.406 5
## 26 Germany Western Europe 6.750 5
## 2 Iceland Western Europe 7.561 5
## 18 Ireland Western Europe 6.940 5
## 17 Luxembourg Western Europe 6.946 5
## 37 Malta Western Europe 6.302 5
## 7 Netherlands Western Europe 7.378 5
## 9 New Zealand Australia and New Zealand 7.286 5
## 4 Norway Western Europe 7.522 5
## 28 Qatar Middle East and Northern Africa 6.611 5
## 24 Singapore Southeastern Asia 6.798 5
## 8 Sweden Western Europe 7.364 5
## 1 Switzerland Western Europe 7.587 5
## 20 United Arab Emirates Middle East and Northern Africa 6.901 5
## 21 United Kingdom Western Europe 6.867 5
## 15 United States North America 7.119 5
## 109 Bangladesh Southern Asia 4.694 6
## 128 Botswana Sub-Saharan Africa 4.332 6
## 152 Burkina Faso Sub-Saharan Africa 3.587 6
## 157 Burundi Sub-Saharan Africa 2.905 6
## 133 Cameroon Sub-Saharan Africa 4.252 6
## 149 Chad Sub-Saharan Africa 3.667 6
## 139 Congo (Brazzaville) Sub-Saharan Africa 3.989 6
## 120 Congo (Kinshasa) Sub-Saharan Africa 4.517 6
## 122 Ethiopia Sub-Saharan Africa 4.512 6
## 143 Gabon Sub-Saharan Africa 3.896 6
## 114 Ghana Sub-Saharan Africa 4.633 6
## 105 Honduras Latin America and Caribbean 4.788 6
## 151 Ivory Coast Sub-Saharan Africa 3.655 6
## 77 Kyrgyzstan Central and Eastern Europe 5.286 6
## 116 Liberia Sub-Saharan Africa 4.571 6
## 147 Madagascar Sub-Saharan Africa 3.681 6
## 138 Mali Sub-Saharan Africa 3.995 6
## 124 Mauritania Sub-Saharan Africa 4.436 6
## 52 Moldova Central and Eastern Europe 5.889 6
## 92 Morocco Middle East and Northern Africa 5.013 6
## 121 Nepal Southern Asia 4.514 6
## 144 Niger Sub-Saharan Africa 3.845 6
## 78 Nigeria Sub-Saharan Africa 5.268 6
## 154 Rwanda Sub-Saharan Africa 3.465 6
## 142 Senegal Sub-Saharan Africa 3.904 6
## 123 Sierra Leone Sub-Saharan Africa 4.507 6
## 113 South Africa Sub-Saharan Africa 4.642 6
## 106 Tajikistan Central and Eastern Europe 4.786 6
## 146 Tanzania Sub-Saharan Africa 3.781 6
## 141 Uganda Sub-Saharan Africa 3.931 6
## 136 Yemen Middle East and Northern Africa 4.077 6
## 85 Zambia Sub-Saharan Africa 5.129 6
## 115 Zimbabwe Sub-Saharan Africa 4.610 6
plot(data, col = Cl_2015$Six_All)
Cl_diff_2015 <- H_diff[,1:3]
colnames(Cl_diff_2015) <- c( "Country" , "Region" , "2015_S")
Cl_diff_2015[,4:7] <- Cl_2015[,4:7]
rmr <- order(Cl_diff_2015[,3])
Cl_diff_2015[rmr,]
## Country Region 2015_S Two_All
## 157 Burundi Sub-Saharan Africa 1.07198 1
## 158 Togo Sub-Saharan Africa 1.27174 1
## 131 Malawi Sub-Saharan Africa 1.48409 1
## 153 Afghanistan Southern Asia 1.62290 1
## 120 Congo (Kinshasa) Sub-Saharan Africa 1.64988 1
## 150 Guinea Sub-Saharan Africa 1.66428 1
## 155 Benin Sub-Saharan Africa 1.70672 1
## 149 Chad Sub-Saharan Africa 1.72404 1
## 116 Liberia Sub-Saharan Africa 1.79371 1
## 147 Madagascar Sub-Saharan Africa 1.83000 1
## 144 Niger Sub-Saharan Africa 1.96623 1
## 123 Sierra Leone Sub-Saharan Africa 1.99691 1
## 122 Ethiopia Sub-Saharan Africa 2.06324 1
## 81 Pakistan Southern Asia 2.08691 1
## 152 Burkina Faso Sub-Saharan Africa 2.12206 1
## 136 Yemen Middle East and Northern Africa 2.15387 1
## 115 Zimbabwe Sub-Saharan Africa 2.16809 1
## 109 Bangladesh Southern Asia 2.17633 1
## 138 Mali Sub-Saharan Africa 2.20207 1
## 151 Ivory Coast Sub-Saharan Africa 2.23777 1
## 119 Haiti Latin America and Caribbean 2.27627 1
## 117 India Southern Asia 2.28987 1
## 133 Cameroon Sub-Saharan Africa 2.30129 1
## 139 Congo (Brazzaville) Sub-Saharan Africa 2.30765 1
## 124 Mauritania Sub-Saharan Africa 2.31827 1
## 114 Ghana Sub-Saharan Africa 2.32381 1
## 78 Nigeria Sub-Saharan Africa 2.37481 1
## 146 Tanzania Sub-Saharan Africa 2.40021 1
## 142 Senegal Sub-Saharan Africa 2.46005 1
## 85 Zambia Sub-Saharan Africa 2.49470 1
## 141 Uganda Sub-Saharan Africa 2.50334 1
## 121 Nepal Southern Asia 2.55763 1
## 92 Morocco Middle East and Northern Africa 2.55927 1
## 127 Armenia Central and Eastern Europe 2.59127 1
## 135 Egypt Middle East and Northern Africa 2.59473 1
## 107 Tunisia Middle East and Northern Africa 2.61434 1
## 125 Kenya Sub-Saharan Africa 2.63345 1
## 108 Palestinian Territories Middle East and Northern Africa 2.67116 1
## 106 Tajikistan Central and Eastern Europe 2.67201 1
## 156 Syria Middle East and Northern Africa 2.67742 1
## 130 Georgia Central and Eastern Europe 2.70159 1
## 112 Iraq Middle East and Northern Africa 2.72365 1
## 52 Moldova Central and Eastern Europe 2.78188 1
## 154 Rwanda Sub-Saharan Africa 2.79458 1
## 69 Kosovo Central and Eastern Europe 2.82321 1
## 145 Cambodia Southeastern Asia 2.83705 1
## 128 Botswana Sub-Saharan Africa 2.87019 1
## 96 Bosnia and Herzegovina Central and Eastern Europe 2.88533 1
## 129 Myanmar Southeastern Asia 2.88895 1
## 143 Gabon Sub-Saharan Africa 2.89705 1
## 113 South Africa Sub-Saharan Africa 2.92244 1
## 105 Honduras Latin America and Caribbean 2.94392 1
## 110 Iran Middle East and Northern Africa 2.99160 1
## 62 Croatia Central and Eastern Europe 3.00486 1
## 77 Kyrgyzstan Central and Eastern Europe 3.05330 1
## 102 Greece Western Europe 3.05599 1
## 95 Albania Central and Eastern Europe 3.06006 1
## 51 Bolivia Latin America and Caribbean 3.06666 1
## 83 Montenegro Central and Eastern Europe 3.09183 1
## 42 El Salvador Latin America and Caribbean 3.09500 1
## 87 Serbia Central and Eastern Europe 3.09800 1
## 111 Ukraine Central and Eastern Europe 3.10960 1
## 75 Vietnam Southeastern Asia 3.15827 1
## 68 Algeria Middle East and Northern Africa 3.17291 1
## 86 Romania Central and Eastern Europe 3.19271 1
## 80 Azerbaijan Central and Eastern Europe 3.21127 1
## 58 Peru Latin America and Caribbean 3.22950 1
## 76 Turkey Middle East and Northern Africa 3.24672 1
## 103 Lebanon Middle East and Northern Africa 3.26841 1
## 84 China Eastern Asia 3.27960 1
## 82 Jordan Middle East and Northern Africa 3.31204 1
## 134 Bulgaria Central and Eastern Europe 3.31809 1
## 90 Philippines Southeastern Asia 3.31940 1
## 43 Guatemala Latin America and Caribbean 3.38045 1
## 56 Lithuania Central and Eastern Europe 3.38651 1
## 65 Jamaica Latin America and Caribbean 3.38862 2
## 48 Ecuador Latin America and Caribbean 3.43558 1
## 64 Russia Central and Eastern Europe 3.44206 1
## 89 Latvia Central and Eastern Europe 3.47585 1
## 57 Nicaragua Latin America and Caribbean 3.50393 1
## 100 Mongolia Eastern Asia 3.52641 2
## 74 Indonesia Southeastern Asia 3.53501 2
## 104 Hungary Central and Eastern Europe 3.55926 1
## 14 Mexico Latin America and Caribbean 3.58486 1
## 132 Sri Lanka Southern Asia 3.59992 1
## 54 Kazakhstan Central and Eastern Europe 3.60771 2
## 79 Bhutan Southern Asia 3.61506 2
## 23 Venezuela Latin America and Caribbean 3.61869 2
## 33 Colombia Latin America and Caribbean 3.61963 2
## 63 Libya Middle East and Northern Africa 3.66334 2
## 98 Dominican Republic Latin America and Caribbean 3.67195 2
## 70 Turkmenistan Central and Eastern Europe 3.67816 2
## 59 Belarus Central and Eastern Europe 3.68210 2
## 53 Paraguay Latin America and Caribbean 3.68904 2
## 71 Mauritius Sub-Saharan Africa 3.71555 2
## 16 Brazil Latin America and Caribbean 3.72299 2
## 30 Argentina Latin America and Caribbean 3.73800 2
## 45 Slovakia Central and Eastern Europe 3.74861 1
## 47 South Korea Eastern Asia 3.76422 1
## 44 Uzbekistan Central and Eastern Europe 3.76559 1
## 67 Cyprus Western Europe 3.79969 1
## 31 Czech Republic Central and Eastern Europe 3.82718 2
## 88 Portugal Western Europe 3.83738 2
## 73 Estonia Central and Eastern Europe 3.84118 2
## 61 Malaysia Southeastern Asia 3.88459 2
## 50 Italy Western Europe 3.92282 1
## 60 Poland Central and Eastern Europe 3.92535 2
## 25 Panama Latin America and Caribbean 3.93752 2
## 35 Saudi Arabia Middle East and Northern Africa 3.97228 2
## 27 Chile Latin America and Caribbean 3.99415 2
## 12 Costa Rica Latin America and Caribbean 4.04872 2
## 34 Thailand Southeastern Asia 4.13555 2
## 32 Uruguay Latin America and Caribbean 4.16358 2
## 11 Israel Middle East and Northern Africa 4.18946 2
## 36 Spain Western Europe 4.20533 2
## 49 Bahrain Middle East and Northern Africa 4.22203 2
## 55 Slovenia Central and Eastern Europe 4.23217 2
## 46 Japan Eastern Asia 4.30265 2
## 29 France Western Europe 4.36374 2
## 39 Kuwait Middle East and Northern Africa 4.41866 2
## 19 Belgium Western Europe 4.52216 2
## 15 United States North America 4.60889 2
## 26 Germany Western Europe 4.63431 2
## 37 Malta Western Europe 4.65320 2
## 20 United Arab Emirates Middle East and Northern Africa 4.65357 2
## 13 Austria Western Europe 4.66680 2
## 6 Finland Western Europe 4.78645 2
## 2 Iceland Western Europe 4.85899 2
## 21 United Kingdom Western Europe 4.89706 2
## 7 Netherlands Western Europe 4.91230 2
## 24 Singapore Southeastern Asia 4.91299 2
## 18 Ireland Western Europe 4.96430 2
## 5 Canada North America 4.97524 2
## 17 Luxembourg Western Europe 4.97639 2
## 8 Sweden Western Europe 4.99281 2
## 10 Australia Australia and New Zealand 5.01754 2
## 9 New Zealand Australia and New Zealand 5.02175 2
## 3 Denmark Western Europe 5.03496 2
## 28 Qatar Middle East and Northern Africa 5.05426 2
## 4 Norway Western Europe 5.05669 2
## 1 Switzerland Western Europe 5.06962 2
## Three_All Mix_G Six_All
## 157 1 4 6
## 158 1 2 2
## 131 1 16 2
## 153 1 2 2
## 120 1 2 6
## 150 1 2 2
## 155 1 2 2
## 149 1 2 6
## 116 1 2 6
## 147 1 2 6
## 144 1 2 6
## 123 1 2 6
## 122 1 2 6
## 81 1 12 2
## 152 1 2 6
## 136 1 2 6
## 115 1 2 6
## 109 1 2 6
## 138 1 2 6
## 151 1 2 6
## 119 1 12 2
## 117 1 2 2
## 133 1 2 6
## 139 1 2 6
## 124 1 12 6
## 114 1 2 6
## 78 1 2 6
## 146 1 2 6
## 142 1 2 6
## 85 1 2 6
## 141 1 12 6
## 121 1 2 6
## 92 1 2 6
## 127 3 12 1
## 135 3 2 1
## 107 3 2 1
## 125 1 2 3
## 108 3 2 1
## 106 1 2 6
## 156 1 12 2
## 130 1 5 2
## 112 3 10 1
## 52 3 14 6
## 154 1 12 6
## 69 3 12 1
## 145 1 2 3
## 128 1 9 6
## 96 3 12 1
## 129 1 12 3
## 143 1 2 6
## 113 1 2 6
## 105 3 2 6
## 110 1 2 2
## 62 3 12 1
## 77 3 13 6
## 102 3 12 1
## 95 3 2 1
## 51 3 2 3
## 83 3 12 1
## 42 3 2 1
## 87 3 12 1
## 111 3 12 1
## 75 3 2 1
## 68 3 12 1
## 86 3 12 1
## 80 3 12 1
## 58 3 12 1
## 76 3 12 1
## 103 3 12 1
## 84 3 12 1
## 82 3 12 1
## 134 3 12 1
## 90 3 2 3
## 43 3 2 3
## 56 3 12 1
## 65 3 12 3
## 48 3 12 1
## 64 3 8 1
## 89 3 12 1
## 57 3 12 4
## 100 3 12 3
## 74 3 12 3
## 104 3 12 1
## 14 3 12 1
## 132 3 12 3
## 54 3 2 1
## 79 3 12 3
## 23 3 12 1
## 33 3 12 3
## 63 3 12 1
## 98 3 12 3
## 70 3 6 4
## 59 3 12 1
## 53 3 12 3
## 71 3 12 3
## 16 3 1 1
## 30 3 12 1
## 45 3 12 1
## 47 3 12 4
## 44 3 12 4
## 67 3 12 4
## 31 3 12 1
## 88 3 12 1
## 73 3 12 1
## 61 3 12 3
## 50 3 12 4
## 60 3 12 3
## 25 3 12 3
## 35 3 12 4
## 27 3 12 4
## 12 3 12 4
## 34 3 12 3
## 32 3 12 4
## 11 3 12 4
## 36 3 12 4
## 49 3 12 4
## 55 3 12 3
## 46 3 12 4
## 29 3 3 4
## 39 2 7 4
## 19 2 12 5
## 15 2 12 5
## 26 2 12 5
## 37 2 12 5
## 20 2 12 5
## 13 2 12 5
## 6 2 12 5
## 2 2 15 5
## 21 2 12 5
## 7 2 12 5
## 24 2 12 5
## 18 2 12 5
## 5 2 12 5
## 17 2 12 5
## 8 2 12 5
## 10 2 12 5
## 9 2 12 5
## 3 2 12 5
## 28 2 11 5
## 4 2 12 5
## 1 2 12 5
cor(data)
## Economy..GDP.per.Capita. Family
## Economy..GDP.per.Capita. 1.00000000 0.6535811
## Family 0.65358108 1.0000000
## Health..Life.Expectancy. 0.81990199 0.5451948
## Freedom 0.36246552 0.5033146
## Trust..Government.Corruption. 0.36478180 0.2408645
## Generosity -0.01479333 0.0947067
## Health..Life.Expectancy. Freedom
## Economy..GDP.per.Capita. 0.81990199 0.3624655
## Family 0.54519484 0.5033146
## Health..Life.Expectancy. 1.00000000 0.3332792
## Freedom 0.33327919 1.0000000
## Trust..Government.Corruption. 0.26926803 0.5103089
## Generosity 0.08559351 0.3616791
## Trust..Government.Corruption. Generosity
## Economy..GDP.per.Capita. 0.3647818 -0.01479333
## Family 0.2408645 0.09470670
## Health..Life.Expectancy. 0.2692680 0.08559351
## Freedom 0.5103089 0.36167905
## Trust..Government.Corruption. 1.0000000 0.25052023
## Generosity 0.2505202 1.00000000
Taking out GDP data and re running clusters
data <- data[,-1]
t.out <- teigen(x=data,Gs=1:20,models="UUUU")
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0 secs | Approx. remaining: 0.7 secs | 5% completeTime taken: 0.1 secs | Approx. remaining: 0.7 secs | 10% completeTime taken: 0.2 secs | Approx. remaining: 1.1 secs | 15% completeTime taken: 0.3 secs | Approx. remaining: 1.3 secs | 20% completeTime taken: 0.5 secs | Approx. remaining: 1.4 secs | 25% completeTime taken: 0.6 secs | Approx. remaining: 1.5 secs | 30% completeTime taken: 0.9 secs | Approx. remaining: 1.6 secs | 35% completeTime taken: 0.9 secs | Approx. remaining: 1.3 secs | 40% completeTime taken: 0.9 secs | Approx. remaining: 1.1 secs | 45% completeTime taken: 0.9 secs | Approx. remaining: 0.9 secs | 50% completeTime taken: 0.9 secs | Approx. remaining: 0.7 secs | 55% completeTime taken: 0.9 secs | Approx. remaining: 0.6 secs | 60% completeTime taken: 0.9 secs | Approx. remaining: 0.5 secs | 65% completeTime taken: 0.9 secs | Approx. remaining: 0.4 secs | 70% completeTime taken: 0.9 secs | Approx. remaining: 0.3 secs | 75% completeTime taken: 0.9 secs | Approx. remaining: 0.2 secs | 80% completeTime taken: 0.9 secs | Approx. remaining: 0.2 secs | 85% completeTime taken: 0.9 secs | Approx. remaining: 0.1 secs | 90% completeTime taken: 0.9 secs | Approx. remaining: 0 secs | 95% completeTime taken: 0.9 secs | Approx. remaining: 0 secs | 100% complete
print(t.out)
## BIC and ICL select the same model and groups.
## The best model (BIC of -1844.96, ICL of -1853.0265) is UUUU with G=2
print(t.out$allbic)
## G=1 G=2 G=3 G=4 G=5 G=6 G=7 G=8
## -1935.977 -1844.965 -1863.939 -1912.681 -1980.254 -2067.461 -2109.001 -Inf
## G=9 G=10 G=11 G=12 G=13 G=14 G=15 G=16
## -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf
## G=17 G=18 G=19 G=20
## -Inf -Inf -Inf -Inf
print(t.out$parameters$df)
## [1] 31.528751 3.711905
Clustering two groups
colnames(Cl_2015)[3] <- "2015_S"
Cl_2015$Two_Noecon <- t.out$classification
rmr <- order(Cl_2015[,3])
Cl_2015[rmr, c(1, 3,4, 8)]
## Country 2015_S Two_All Two_Noecon
## 158 Togo 2.839 1 1
## 157 Burundi 2.905 1 1
## 156 Syria 3.006 1 1
## 155 Benin 3.340 1 1
## 154 Rwanda 3.465 1 2
## 153 Afghanistan 3.575 1 1
## 152 Burkina Faso 3.587 1 1
## 151 Ivory Coast 3.655 1 1
## 150 Guinea 3.656 1 1
## 149 Chad 3.667 1 1
## 147 Madagascar 3.681 1 1
## 146 Tanzania 3.781 1 1
## 145 Cambodia 3.819 1 1
## 144 Niger 3.845 1 1
## 143 Gabon 3.896 1 1
## 142 Senegal 3.904 1 1
## 141 Uganda 3.931 1 1
## 139 Congo (Brazzaville) 3.989 1 1
## 138 Mali 3.995 1 1
## 136 Yemen 4.077 1 1
## 135 Egypt 4.194 1 1
## 134 Bulgaria 4.218 1 1
## 133 Cameroon 4.252 1 1
## 132 Sri Lanka 4.271 1 2
## 131 Malawi 4.292 1 1
## 130 Georgia 4.297 1 1
## 129 Myanmar 4.307 1 2
## 128 Botswana 4.332 1 1
## 127 Armenia 4.350 1 1
## 125 Kenya 4.419 1 1
## 124 Mauritania 4.436 1 1
## 123 Sierra Leone 4.507 1 1
## 122 Ethiopia 4.512 1 1
## 121 Nepal 4.514 1 1
## 120 Congo (Kinshasa) 4.517 1 1
## 119 Haiti 4.518 1 1
## 117 India 4.565 1 1
## 116 Liberia 4.571 1 1
## 115 Zimbabwe 4.610 1 1
## 114 Ghana 4.633 1 1
## 113 South Africa 4.642 1 1
## 112 Iraq 4.677 1 1
## 111 Ukraine 4.681 1 1
## 110 Iran 4.686 1 1
## 109 Bangladesh 4.694 1 1
## 108 Palestinian Territories 4.715 1 1
## 107 Tunisia 4.739 1 1
## 106 Tajikistan 4.786 1 1
## 105 Honduras 4.788 1 1
## 104 Hungary 4.800 1 1
## 103 Lebanon 4.839 1 1
## 102 Greece 4.857 1 1
## 100 Mongolia 4.874 2 1
## 98 Dominican Republic 4.885 2 1
## 96 Bosnia and Herzegovina 4.949 1 1
## 95 Albania 4.959 1 1
## 92 Morocco 5.013 1 1
## 90 Philippines 5.073 1 1
## 89 Latvia 5.098 1 1
## 88 Portugal 5.102 2 1
## 87 Serbia 5.123 1 1
## 86 Romania 5.124 1 1
## 85 Zambia 5.129 1 1
## 84 China 5.140 1 1
## 82 Jordan 5.192 1 1
## 83 Montenegro 5.192 1 1
## 81 Pakistan 5.194 1 1
## 80 Azerbaijan 5.212 1 1
## 79 Bhutan 5.253 2 2
## 78 Nigeria 5.268 1 1
## 77 Kyrgyzstan 5.286 1 1
## 76 Turkey 5.332 1 1
## 75 Vietnam 5.360 1 1
## 74 Indonesia 5.399 2 2
## 73 Estonia 5.429 2 1
## 71 Mauritius 5.477 2 1
## 70 Turkmenistan 5.548 2 1
## 69 Kosovo 5.589 1 1
## 68 Algeria 5.605 1 1
## 67 Cyprus 5.689 1 1
## 65 Jamaica 5.709 2 1
## 64 Russia 5.716 1 1
## 63 Libya 5.754 2 1
## 62 Croatia 5.759 1 1
## 61 Malaysia 5.770 2 2
## 60 Poland 5.791 2 1
## 59 Belarus 5.813 2 1
## 58 Peru 5.824 1 1
## 57 Nicaragua 5.828 1 2
## 56 Lithuania 5.833 1 1
## 55 Slovenia 5.848 2 2
## 54 Kazakhstan 5.855 2 1
## 53 Paraguay 5.878 2 1
## 52 Moldova 5.889 1 1
## 51 Bolivia 5.890 1 1
## 50 Italy 5.948 1 1
## 49 Bahrain 5.960 2 1
## 48 Ecuador 5.975 1 1
## 47 South Korea 5.984 1 1
## 46 Japan 5.987 2 1
## 45 Slovakia 5.995 1 1
## 44 Uzbekistan 6.003 1 1
## 43 Guatemala 6.123 1 1
## 42 El Salvador 6.130 1 1
## 39 Kuwait 6.295 2 2
## 37 Malta 6.302 2 2
## 36 Spain 6.329 2 1
## 35 Saudi Arabia 6.411 2 1
## 34 Thailand 6.455 2 2
## 33 Colombia 6.477 2 1
## 32 Uruguay 6.485 2 2
## 31 Czech Republic 6.505 2 1
## 30 Argentina 6.574 2 1
## 29 France 6.575 2 1
## 28 Qatar 6.611 2 2
## 27 Chile 6.670 2 1
## 26 Germany 6.750 2 2
## 25 Panama 6.786 2 2
## 24 Singapore 6.798 2 2
## 23 Venezuela 6.810 2 1
## 21 United Kingdom 6.867 2 2
## 20 United Arab Emirates 6.901 2 2
## 19 Belgium 6.937 2 2
## 18 Ireland 6.940 2 2
## 17 Luxembourg 6.946 2 2
## 16 Brazil 6.983 2 1
## 15 United States 7.119 2 2
## 14 Mexico 7.187 1 1
## 13 Austria 7.200 2 2
## 12 Costa Rica 7.226 2 1
## 11 Israel 7.278 2 1
## 10 Australia 7.284 2 2
## 9 New Zealand 7.286 2 2
## 8 Sweden 7.364 2 2
## 7 Netherlands 7.378 2 2
## 6 Finland 7.406 2 2
## 5 Canada 7.427 2 2
## 4 Norway 7.522 2 2
## 3 Denmark 7.527 2 2
## 2 Iceland 7.561 2 2
## 1 Switzerland 7.587 2 2
Six without econ
t.out <- teigen(x=data,Gs=6,models="UUUU")
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0.1 secs | Approx. remaining: 0 secs | 100% complete
print(t.out$parameters$df)
## [1] 136.96992 56.31246 200.00000 2.70580 135.61622 154.46956
Cl_2015$Six_Noecon <- t.out$classification
rmr <- order(Cl_2015[,3])
Cl_2015[rmr, c(1, 3,7,9)]
## Country 2015_S Six_All Six_Noecon
## 158 Togo 2.839 2 3
## 157 Burundi 2.905 6 3
## 156 Syria 3.006 2 3
## 155 Benin 3.340 2 6
## 154 Rwanda 3.465 6 4
## 153 Afghanistan 3.575 2 3
## 152 Burkina Faso 3.587 6 6
## 151 Ivory Coast 3.655 6 6
## 150 Guinea 3.656 2 3
## 149 Chad 3.667 6 6
## 147 Madagascar 3.681 6 6
## 146 Tanzania 3.781 6 6
## 145 Cambodia 3.819 3 6
## 144 Niger 3.845 6 6
## 143 Gabon 3.896 6 5
## 142 Senegal 3.904 6 6
## 141 Uganda 3.931 6 6
## 139 Congo (Brazzaville) 3.989 6 6
## 138 Mali 3.995 6 6
## 136 Yemen 4.077 6 5
## 135 Egypt 4.194 1 1
## 134 Bulgaria 4.218 1 1
## 133 Cameroon 4.252 6 6
## 132 Sri Lanka 4.271 3 2
## 131 Malawi 4.292 2 3
## 130 Georgia 4.297 2 3
## 129 Myanmar 4.307 3 2
## 128 Botswana 4.332 6 6
## 127 Armenia 4.350 1 1
## 125 Kenya 4.419 3 6
## 124 Mauritania 4.436 6 6
## 123 Sierra Leone 4.507 6 6
## 122 Ethiopia 4.512 6 6
## 121 Nepal 4.514 6 6
## 120 Congo (Kinshasa) 4.517 6 6
## 119 Haiti 4.518 2 3
## 117 India 4.565 2 6
## 116 Liberia 4.571 6 6
## 115 Zimbabwe 4.610 6 6
## 114 Ghana 4.633 6 6
## 113 South Africa 4.642 6 6
## 112 Iraq 4.677 1 1
## 111 Ukraine 4.681 1 1
## 110 Iran 4.686 2 6
## 109 Bangladesh 4.694 6 6
## 108 Palestinian Territories 4.715 1 1
## 107 Tunisia 4.739 1 1
## 106 Tajikistan 4.786 6 6
## 105 Honduras 4.788 6 1
## 104 Hungary 4.800 1 1
## 103 Lebanon 4.839 1 1
## 102 Greece 4.857 1 1
## 100 Mongolia 4.874 3 2
## 98 Dominican Republic 4.885 3 5
## 96 Bosnia and Herzegovina 4.949 1 1
## 95 Albania 4.959 1 1
## 92 Morocco 5.013 6 5
## 90 Philippines 5.073 3 5
## 89 Latvia 5.098 1 1
## 88 Portugal 5.102 1 1
## 87 Serbia 5.123 1 1
## 86 Romania 5.124 1 1
## 85 Zambia 5.129 6 6
## 84 China 5.140 1 5
## 82 Jordan 5.192 1 5
## 83 Montenegro 5.192 1 1
## 81 Pakistan 5.194 2 3
## 80 Azerbaijan 5.212 1 5
## 79 Bhutan 5.253 3 2
## 78 Nigeria 5.268 6 6
## 77 Kyrgyzstan 5.286 6 2
## 76 Turkey 5.332 1 1
## 75 Vietnam 5.360 1 5
## 74 Indonesia 5.399 3 2
## 73 Estonia 5.429 1 5
## 71 Mauritius 5.477 3 2
## 70 Turkmenistan 5.548 4 5
## 69 Kosovo 5.589 1 6
## 68 Algeria 5.605 1 5
## 67 Cyprus 5.689 4 1
## 65 Jamaica 5.709 3 2
## 64 Russia 5.716 1 1
## 63 Libya 5.754 1 1
## 62 Croatia 5.759 1 1
## 61 Malaysia 5.770 3 2
## 60 Poland 5.791 3 2
## 59 Belarus 5.813 1 5
## 58 Peru 5.824 1 1
## 57 Nicaragua 5.828 4 2
## 56 Lithuania 5.833 1 1
## 55 Slovenia 5.848 3 2
## 54 Kazakhstan 5.855 1 5
## 53 Paraguay 5.878 3 2
## 52 Moldova 5.889 6 1
## 51 Bolivia 5.890 3 5
## 50 Italy 5.948 4 1
## 49 Bahrain 5.960 4 5
## 48 Ecuador 5.975 1 5
## 47 South Korea 5.984 4 1
## 46 Japan 5.987 4 5
## 45 Slovakia 5.995 1 1
## 44 Uzbekistan 6.003 4 5
## 43 Guatemala 6.123 3 2
## 42 El Salvador 6.130 1 5
## 39 Kuwait 6.295 4 5
## 37 Malta 6.302 5 2
## 36 Spain 6.329 4 1
## 35 Saudi Arabia 6.411 4 5
## 34 Thailand 6.455 3 2
## 33 Colombia 6.477 3 2
## 32 Uruguay 6.485 4 5
## 31 Czech Republic 6.505 1 1
## 30 Argentina 6.574 1 1
## 29 France 6.575 4 5
## 28 Qatar 6.611 5 4
## 27 Chile 6.670 4 1
## 26 Germany 6.750 5 2
## 25 Panama 6.786 3 2
## 24 Singapore 6.798 5 4
## 23 Venezuela 6.810 1 1
## 21 United Kingdom 6.867 5 4
## 20 United Arab Emirates 6.901 5 4
## 19 Belgium 6.937 5 5
## 18 Ireland 6.940 5 4
## 17 Luxembourg 6.946 5 4
## 16 Brazil 6.983 1 5
## 15 United States 7.119 5 2
## 14 Mexico 7.187 1 5
## 13 Austria 7.200 5 2
## 12 Costa Rica 7.226 4 2
## 11 Israel 7.278 4 1
## 10 Australia 7.284 5 4
## 9 New Zealand 7.286 5 4
## 8 Sweden 7.364 5 4
## 7 Netherlands 7.378 5 4
## 6 Finland 7.406 5 4
## 5 Canada 7.427 5 4
## 4 Norway 7.522 5 4
## 3 Denmark 7.527 5 4
## 2 Iceland 7.561 5 2
## 1 Switzerland 7.587 5 4
Table of Six clusters Econ and no Econ
print(table(Cl_2015$Region, Cl_2015$Six_Noecon))
##
## 1 2 3 4 5 6
## Australia and New Zealand 0 0 0 2 0 0
## Central and Eastern Europe 16 3 1 0 6 2
## Eastern Asia 1 1 0 0 2 0
## Latin America and Caribbean 5 7 1 0 7 0
## Middle East and Northern Africa 8 0 1 2 7 1
## North America 0 1 0 1 0 0
## Southeastern Asia 0 4 0 1 2 1
## Southern Asia 0 2 2 0 0 3
## Sub-Saharan Africa 0 1 4 1 1 24
## Western Europe 5 4 0 9 2 0
print(table(Cl_2015$Region, Cl_2015$Six_All))
##
## 1 2 3 4 5 6
## Australia and New Zealand 0 0 0 0 2 0
## Central and Eastern Europe 20 1 2 2 0 3
## Eastern Asia 1 0 1 2 0 0
## Latin America and Caribbean 7 1 7 4 0 1
## Middle East and Northern Africa 9 2 0 4 2 2
## North America 0 0 0 0 2 0
## Southeastern Asia 1 0 6 0 1 0
## Southern Asia 0 3 2 0 0 2
## Sub-Saharan Africa 0 4 2 0 0 25
## Western Europe 2 0 0 4 14 0
Cl_diff_2015[,8:9] <- Cl_2015[,8:9]
rmr <- order(Cl_diff_2015[,3])
Cl_diff_2015[rmr, c(1,3,8,9)]
## Country 2015_S Two_Noecon Six_Noecon
## 157 Burundi 1.07198 1 3
## 158 Togo 1.27174 1 3
## 131 Malawi 1.48409 1 3
## 153 Afghanistan 1.62290 1 3
## 120 Congo (Kinshasa) 1.64988 1 6
## 150 Guinea 1.66428 1 3
## 155 Benin 1.70672 1 6
## 149 Chad 1.72404 1 6
## 116 Liberia 1.79371 1 6
## 147 Madagascar 1.83000 1 6
## 144 Niger 1.96623 1 6
## 123 Sierra Leone 1.99691 1 6
## 122 Ethiopia 2.06324 1 6
## 81 Pakistan 2.08691 1 3
## 152 Burkina Faso 2.12206 1 6
## 136 Yemen 2.15387 1 5
## 115 Zimbabwe 2.16809 1 6
## 109 Bangladesh 2.17633 1 6
## 138 Mali 2.20207 1 6
## 151 Ivory Coast 2.23777 1 6
## 119 Haiti 2.27627 1 3
## 117 India 2.28987 1 6
## 133 Cameroon 2.30129 1 6
## 139 Congo (Brazzaville) 2.30765 1 6
## 124 Mauritania 2.31827 1 6
## 114 Ghana 2.32381 1 6
## 78 Nigeria 2.37481 1 6
## 146 Tanzania 2.40021 1 6
## 142 Senegal 2.46005 1 6
## 85 Zambia 2.49470 1 6
## 141 Uganda 2.50334 1 6
## 121 Nepal 2.55763 1 6
## 92 Morocco 2.55927 1 5
## 127 Armenia 2.59127 1 1
## 135 Egypt 2.59473 1 1
## 107 Tunisia 2.61434 1 1
## 125 Kenya 2.63345 1 6
## 108 Palestinian Territories 2.67116 1 1
## 106 Tajikistan 2.67201 1 6
## 156 Syria 2.67742 1 3
## 130 Georgia 2.70159 1 3
## 112 Iraq 2.72365 1 1
## 52 Moldova 2.78188 1 1
## 154 Rwanda 2.79458 2 4
## 69 Kosovo 2.82321 1 6
## 145 Cambodia 2.83705 1 6
## 128 Botswana 2.87019 1 6
## 96 Bosnia and Herzegovina 2.88533 1 1
## 129 Myanmar 2.88895 2 2
## 143 Gabon 2.89705 1 5
## 113 South Africa 2.92244 1 6
## 105 Honduras 2.94392 1 1
## 110 Iran 2.99160 1 6
## 62 Croatia 3.00486 1 1
## 77 Kyrgyzstan 3.05330 1 2
## 102 Greece 3.05599 1 1
## 95 Albania 3.06006 1 1
## 51 Bolivia 3.06666 1 5
## 83 Montenegro 3.09183 1 1
## 42 El Salvador 3.09500 1 5
## 87 Serbia 3.09800 1 1
## 111 Ukraine 3.10960 1 1
## 75 Vietnam 3.15827 1 5
## 68 Algeria 3.17291 1 5
## 86 Romania 3.19271 1 1
## 80 Azerbaijan 3.21127 1 5
## 58 Peru 3.22950 1 1
## 76 Turkey 3.24672 1 1
## 103 Lebanon 3.26841 1 1
## 84 China 3.27960 1 5
## 82 Jordan 3.31204 1 5
## 134 Bulgaria 3.31809 1 1
## 90 Philippines 3.31940 1 5
## 43 Guatemala 3.38045 1 2
## 56 Lithuania 3.38651 1 1
## 65 Jamaica 3.38862 1 2
## 48 Ecuador 3.43558 1 5
## 64 Russia 3.44206 1 1
## 89 Latvia 3.47585 1 1
## 57 Nicaragua 3.50393 2 2
## 100 Mongolia 3.52641 1 2
## 74 Indonesia 3.53501 2 2
## 104 Hungary 3.55926 1 1
## 14 Mexico 3.58486 1 5
## 132 Sri Lanka 3.59992 2 2
## 54 Kazakhstan 3.60771 1 5
## 79 Bhutan 3.61506 2 2
## 23 Venezuela 3.61869 1 1
## 33 Colombia 3.61963 1 2
## 63 Libya 3.66334 1 1
## 98 Dominican Republic 3.67195 1 5
## 70 Turkmenistan 3.67816 1 5
## 59 Belarus 3.68210 1 5
## 53 Paraguay 3.68904 1 2
## 71 Mauritius 3.71555 1 2
## 16 Brazil 3.72299 1 5
## 30 Argentina 3.73800 1 1
## 45 Slovakia 3.74861 1 1
## 47 South Korea 3.76422 1 1
## 44 Uzbekistan 3.76559 1 5
## 67 Cyprus 3.79969 1 1
## 31 Czech Republic 3.82718 1 1
## 88 Portugal 3.83738 1 1
## 73 Estonia 3.84118 1 5
## 61 Malaysia 3.88459 2 2
## 50 Italy 3.92282 1 1
## 60 Poland 3.92535 1 2
## 25 Panama 3.93752 2 2
## 35 Saudi Arabia 3.97228 1 5
## 27 Chile 3.99415 1 1
## 12 Costa Rica 4.04872 1 2
## 34 Thailand 4.13555 2 2
## 32 Uruguay 4.16358 2 5
## 11 Israel 4.18946 1 1
## 36 Spain 4.20533 1 1
## 49 Bahrain 4.22203 1 5
## 55 Slovenia 4.23217 2 2
## 46 Japan 4.30265 1 5
## 29 France 4.36374 1 5
## 39 Kuwait 4.41866 2 5
## 19 Belgium 4.52216 2 5
## 15 United States 4.60889 2 2
## 26 Germany 4.63431 2 2
## 37 Malta 4.65320 2 2
## 20 United Arab Emirates 4.65357 2 4
## 13 Austria 4.66680 2 2
## 6 Finland 4.78645 2 4
## 2 Iceland 4.85899 2 2
## 21 United Kingdom 4.89706 2 4
## 7 Netherlands 4.91230 2 4
## 24 Singapore 4.91299 2 4
## 18 Ireland 4.96430 2 4
## 5 Canada 4.97524 2 4
## 17 Luxembourg 4.97639 2 4
## 8 Sweden 4.99281 2 4
## 10 Australia 5.01754 2 4
## 9 New Zealand 5.02175 2 4
## 3 Denmark 5.03496 2 4
## 28 Qatar 5.05426 2 4
## 4 Norway 5.05669 2 4
## 1 Switzerland 5.06962 2 4
t.out <- teigen(x=data,Gs=1:20,models="UUUU", scale = FALSE)
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0.1 secs | Approx. remaining: 2 secs | 5% completeTime taken: 0.9 secs | Approx. remaining: 8.2 secs | 10% completeTime taken: 1.4 secs | Approx. remaining: 8.1 secs | 15% completeTime taken: 2.3 secs | Approx. remaining: 9.2 secs | 20% completeTime taken: 3.2 secs | Approx. remaining: 9.7 secs | 25% completeTime taken: 3.5 secs | Approx. remaining: 8.2 secs | 30% completeTime taken: 4.3 secs | Approx. remaining: 8 secs | 35% completeTime taken: 4.9 secs | Approx. remaining: 7.3 secs | 40% completeTime taken: 4.9 secs | Approx. remaining: 6 secs | 45% completeTime taken: 5.1 secs | Approx. remaining: 5.1 secs | 50% completeTime taken: 5.1 secs | Approx. remaining: 4.2 secs | 55% completeTime taken: 5.1 secs | Approx. remaining: 3.4 secs | 60% completeTime taken: 5.1 secs | Approx. remaining: 2.8 secs | 65% completeTime taken: 5.1 secs | Approx. remaining: 2.2 secs | 70% completeTime taken: 5.1 secs | Approx. remaining: 1.7 secs | 75% completeTime taken: 5.1 secs | Approx. remaining: 1.3 secs | 80% completeTime taken: 5.1 secs | Approx. remaining: 0.9 secs | 85% completeTime taken: 5.1 secs | Approx. remaining: 0.6 secs | 90% completeTime taken: 5.1 secs | Approx. remaining: 0.3 secs | 95% completeTime taken: 5.1 secs | Approx. remaining: 0 secs | 100% complete
test <- Cl_2015[,c(1,3,4, 8 )]
test$unscale_2 <- t.out$classification
rmr <- order(test[,3])
test[rmr,]
## Country 2015_S Two_All Two_Noecon unscale_2
## 153 Afghanistan 3.575 1 1 2
## 95 Albania 4.959 1 1 2
## 68 Algeria 5.605 1 1 2
## 127 Armenia 4.350 1 1 2
## 80 Azerbaijan 5.212 1 1 1
## 109 Bangladesh 4.694 1 1 2
## 155 Benin 3.340 1 1 2
## 51 Bolivia 5.890 1 1 2
## 96 Bosnia and Herzegovina 4.949 1 1 2
## 128 Botswana 4.332 1 1 2
## 134 Bulgaria 4.218 1 1 2
## 152 Burkina Faso 3.587 1 1 2
## 157 Burundi 2.905 1 1 2
## 145 Cambodia 3.819 1 1 2
## 133 Cameroon 4.252 1 1 2
## 149 Chad 3.667 1 1 2
## 84 China 5.140 1 1 2
## 139 Congo (Brazzaville) 3.989 1 1 2
## 120 Congo (Kinshasa) 4.517 1 1 2
## 62 Croatia 5.759 1 1 2
## 67 Cyprus 5.689 1 1 2
## 48 Ecuador 5.975 1 1 1
## 135 Egypt 4.194 1 1 2
## 42 El Salvador 6.130 1 1 1
## 122 Ethiopia 4.512 1 1 2
## 143 Gabon 3.896 1 1 2
## 130 Georgia 4.297 1 1 1
## 114 Ghana 4.633 1 1 2
## 102 Greece 4.857 1 1 2
## 43 Guatemala 6.123 1 1 2
## 150 Guinea 3.656 1 1 2
## 119 Haiti 4.518 1 1 2
## 105 Honduras 4.788 1 1 2
## 104 Hungary 4.800 1 1 2
## 117 India 4.565 1 1 2
## 110 Iran 4.686 1 1 2
## 112 Iraq 4.677 1 1 2
## 50 Italy 5.948 1 1 2
## 151 Ivory Coast 3.655 1 1 2
## 82 Jordan 5.192 1 1 1
## 125 Kenya 4.419 1 1 2
## 69 Kosovo 5.589 1 1 2
## 77 Kyrgyzstan 5.286 1 1 1
## 89 Latvia 5.098 1 1 2
## 103 Lebanon 4.839 1 1 2
## 116 Liberia 4.571 1 1 2
## 56 Lithuania 5.833 1 1 2
## 147 Madagascar 3.681 1 1 2
## 131 Malawi 4.292 1 1 2
## 138 Mali 3.995 1 1 2
## 124 Mauritania 4.436 1 1 2
## 14 Mexico 7.187 1 1 1
## 52 Moldova 5.889 1 1 2
## 83 Montenegro 5.192 1 1 2
## 92 Morocco 5.013 1 1 2
## 129 Myanmar 4.307 1 2 1
## 121 Nepal 4.514 1 1 2
## 57 Nicaragua 5.828 1 2 1
## 144 Niger 3.845 1 1 2
## 78 Nigeria 5.268 1 1 2
## 81 Pakistan 5.194 1 1 2
## 108 Palestinian Territories 4.715 1 1 2
## 58 Peru 5.824 1 1 2
## 90 Philippines 5.073 1 1 2
## 86 Romania 5.124 1 1 2
## 64 Russia 5.716 1 1 2
## 154 Rwanda 3.465 1 2 1
## 142 Senegal 3.904 1 1 2
## 87 Serbia 5.123 1 1 2
## 123 Sierra Leone 4.507 1 1 2
## 45 Slovakia 5.995 1 1 2
## 113 South Africa 4.642 1 1 2
## 47 South Korea 5.984 1 1 2
## 132 Sri Lanka 4.271 1 2 1
## 156 Syria 3.006 1 1 2
## 106 Tajikistan 4.786 1 1 2
## 146 Tanzania 3.781 1 1 2
## 158 Togo 2.839 1 1 2
## 107 Tunisia 4.739 1 1 2
## 76 Turkey 5.332 1 1 2
## 141 Uganda 3.931 1 1 2
## 111 Ukraine 4.681 1 1 2
## 44 Uzbekistan 6.003 1 1 1
## 75 Vietnam 5.360 1 1 2
## 136 Yemen 4.077 1 1 2
## 85 Zambia 5.129 1 1 2
## 115 Zimbabwe 4.610 1 1 2
## 30 Argentina 6.574 2 1 1
## 10 Australia 7.284 2 2 1
## 13 Austria 7.200 2 2 1
## 49 Bahrain 5.960 2 1 1
## 59 Belarus 5.813 2 1 1
## 19 Belgium 6.937 2 2 1
## 79 Bhutan 5.253 2 2 1
## 16 Brazil 6.983 2 1 1
## 5 Canada 7.427 2 2 1
## 27 Chile 6.670 2 1 1
## 33 Colombia 6.477 2 1 1
## 12 Costa Rica 7.226 2 1 1
## 31 Czech Republic 6.505 2 1 2
## 3 Denmark 7.527 2 2 1
## 98 Dominican Republic 4.885 2 1 1
## 73 Estonia 5.429 2 1 1
## 6 Finland 7.406 2 2 1
## 29 France 6.575 2 1 1
## 26 Germany 6.750 2 2 1
## 2 Iceland 7.561 2 2 1
## 74 Indonesia 5.399 2 2 1
## 18 Ireland 6.940 2 2 1
## 11 Israel 7.278 2 1 2
## 65 Jamaica 5.709 2 1 1
## 46 Japan 5.987 2 1 1
## 54 Kazakhstan 5.855 2 1 2
## 39 Kuwait 6.295 2 2 1
## 63 Libya 5.754 2 1 1
## 17 Luxembourg 6.946 2 2 1
## 61 Malaysia 5.770 2 2 1
## 37 Malta 6.302 2 2 1
## 71 Mauritius 5.477 2 1 2
## 100 Mongolia 4.874 2 1 2
## 7 Netherlands 7.378 2 2 1
## 9 New Zealand 7.286 2 2 1
## 4 Norway 7.522 2 2 1
## 25 Panama 6.786 2 2 1
## 53 Paraguay 5.878 2 1 1
## 60 Poland 5.791 2 1 1
## 88 Portugal 5.102 2 1 2
## 28 Qatar 6.611 2 2 1
## 35 Saudi Arabia 6.411 2 1 1
## 24 Singapore 6.798 2 2 1
## 55 Slovenia 5.848 2 2 1
## 36 Spain 6.329 2 1 2
## 8 Sweden 7.364 2 2 1
## 1 Switzerland 7.587 2 2 1
## 34 Thailand 6.455 2 2 1
## 70 Turkmenistan 5.548 2 1 1
## 20 United Arab Emirates 6.901 2 2 1
## 21 United Kingdom 6.867 2 2 1
## 15 United States 7.119 2 2 1
## 32 Uruguay 6.485 2 2 1
## 23 Venezuela 6.810 2 1 1
t.out <- teigen(x=data,Gs=8,models="UUUU", scale = FALSE)
## Time taken:??? | Approx. remaining:??? | 0% completeTime taken: 0.5 secs | Approx. remaining: 0 secs | 100% complete
print(t.out$parameters$df)
## [1] 172.22239 100.48428 154.99903 59.33123 200.00000 188.05131 200.00000
## [8] 98.69036
test$unscale_8 <- t.out$classification
rmr <- order(test[,6])
test[rmr, ]
## Country 2015_S Two_All Two_Noecon unscale_2 unscale_8
## 13 Austria 7.200 2 2 1 1
## 19 Belgium 6.937 2 2 1 1
## 27 Chile 6.670 2 1 1 1
## 29 France 6.575 2 1 1 1
## 26 Germany 6.750 2 2 1 1
## 2 Iceland 7.561 2 2 1 1
## 11 Israel 7.278 2 1 2 1
## 46 Japan 5.987 2 1 1 1
## 37 Malta 6.302 2 2 1 1
## 36 Spain 6.329 2 1 2 1
## 34 Thailand 6.455 2 2 1 1
## 15 United States 7.119 2 2 1 1
## 30 Argentina 6.574 2 1 1 2
## 49 Bahrain 5.960 2 1 1 2
## 59 Belarus 5.813 2 1 1 2
## 16 Brazil 6.983 2 1 1 2
## 33 Colombia 6.477 2 1 1 2
## 12 Costa Rica 7.226 2 1 1 2
## 31 Czech Republic 6.505 2 1 2 2
## 98 Dominican Republic 4.885 2 1 1 2
## 73 Estonia 5.429 2 1 1 2
## 65 Jamaica 5.709 2 1 1 2
## 39 Kuwait 6.295 2 2 1 2
## 56 Lithuania 5.833 1 1 2 2
## 57 Nicaragua 5.828 1 2 1 2
## 25 Panama 6.786 2 2 1 2
## 60 Poland 5.791 2 1 1 2
## 64 Russia 5.716 1 1 2 2
## 35 Saudi Arabia 6.411 2 1 1 2
## 55 Slovenia 5.848 2 2 1 2
## 70 Turkmenistan 5.548 2 1 1 2
## 32 Uruguay 6.485 2 2 1 2
## 44 Uzbekistan 6.003 1 1 1 2
## 23 Venezuela 6.810 2 1 1 2
## 109 Bangladesh 4.694 1 1 2 3
## 51 Bolivia 5.890 1 1 2 3
## 128 Botswana 4.332 1 1 2 3
## 152 Burkina Faso 3.587 1 1 2 3
## 133 Cameroon 4.252 1 1 2 3
## 149 Chad 3.667 1 1 2 3
## 139 Congo (Brazzaville) 3.989 1 1 2 3
## 120 Congo (Kinshasa) 4.517 1 1 2 3
## 122 Ethiopia 4.512 1 1 2 3
## 143 Gabon 3.896 1 1 2 3
## 114 Ghana 4.633 1 1 2 3
## 150 Guinea 3.656 1 1 2 3
## 105 Honduras 4.788 1 1 2 3
## 110 Iran 4.686 1 1 2 3
## 151 Ivory Coast 3.655 1 1 2 3
## 125 Kenya 4.419 1 1 2 3
## 69 Kosovo 5.589 1 1 2 3
## 77 Kyrgyzstan 5.286 1 1 1 3
## 103 Lebanon 4.839 1 1 2 3
## 116 Liberia 4.571 1 1 2 3
## 147 Madagascar 3.681 1 1 2 3
## 138 Mali 3.995 1 1 2 3
## 124 Mauritania 4.436 1 1 2 3
## 52 Moldova 5.889 1 1 2 3
## 100 Mongolia 4.874 2 1 2 3
## 121 Nepal 4.514 1 1 2 3
## 144 Niger 3.845 1 1 2 3
## 78 Nigeria 5.268 1 1 2 3
## 53 Paraguay 5.878 2 1 1 3
## 142 Senegal 3.904 1 1 2 3
## 123 Sierra Leone 4.507 1 1 2 3
## 113 South Africa 4.642 1 1 2 3
## 106 Tajikistan 4.786 1 1 2 3
## 146 Tanzania 3.781 1 1 2 3
## 141 Uganda 3.931 1 1 2 3
## 136 Yemen 4.077 1 1 2 3
## 85 Zambia 5.129 1 1 2 3
## 115 Zimbabwe 4.610 1 1 2 3
## 10 Australia 7.284 2 2 1 4
## 5 Canada 7.427 2 2 1 4
## 3 Denmark 7.527 2 2 1 4
## 6 Finland 7.406 2 2 1 4
## 18 Ireland 6.940 2 2 1 4
## 17 Luxembourg 6.946 2 2 1 4
## 7 Netherlands 7.378 2 2 1 4
## 9 New Zealand 7.286 2 2 1 4
## 4 Norway 7.522 2 2 1 4
## 28 Qatar 6.611 2 2 1 4
## 24 Singapore 6.798 2 2 1 4
## 8 Sweden 7.364 2 2 1 4
## 1 Switzerland 7.587 2 2 1 4
## 20 United Arab Emirates 6.901 2 2 1 4
## 21 United Kingdom 6.867 2 2 1 4
## 145 Cambodia 3.819 1 1 2 5
## 130 Georgia 4.297 1 1 1 5
## 119 Haiti 4.518 1 1 2 5
## 129 Myanmar 4.307 1 2 1 5
## 154 Rwanda 3.465 1 2 1 5
## 156 Syria 3.006 1 1 2 5
## 79 Bhutan 5.253 2 2 1 6
## 67 Cyprus 5.689 1 1 2 6
## 48 Ecuador 5.975 1 1 1 6
## 43 Guatemala 6.123 1 1 2 6
## 74 Indonesia 5.399 2 2 1 6
## 61 Malaysia 5.770 2 2 1 6
## 71 Mauritius 5.477 2 1 2 6
## 14 Mexico 7.187 1 1 1 6
## 90 Philippines 5.073 1 1 2 6
## 47 South Korea 5.984 1 1 2 6
## 132 Sri Lanka 4.271 1 2 1 6
## 75 Vietnam 5.360 1 1 2 6
## 153 Afghanistan 3.575 1 1 2 7
## 155 Benin 3.340 1 1 2 7
## 157 Burundi 2.905 1 1 2 7
## 117 India 4.565 1 1 2 7
## 131 Malawi 4.292 1 1 2 7
## 81 Pakistan 5.194 1 1 2 7
## 158 Togo 2.839 1 1 2 7
## 95 Albania 4.959 1 1 2 8
## 68 Algeria 5.605 1 1 2 8
## 127 Armenia 4.350 1 1 2 8
## 80 Azerbaijan 5.212 1 1 1 8
## 96 Bosnia and Herzegovina 4.949 1 1 2 8
## 134 Bulgaria 4.218 1 1 2 8
## 84 China 5.140 1 1 2 8
## 62 Croatia 5.759 1 1 2 8
## 135 Egypt 4.194 1 1 2 8
## 42 El Salvador 6.130 1 1 1 8
## 102 Greece 4.857 1 1 2 8
## 104 Hungary 4.800 1 1 2 8
## 112 Iraq 4.677 1 1 2 8
## 50 Italy 5.948 1 1 2 8
## 82 Jordan 5.192 1 1 1 8
## 54 Kazakhstan 5.855 2 1 2 8
## 89 Latvia 5.098 1 1 2 8
## 63 Libya 5.754 2 1 1 8
## 83 Montenegro 5.192 1 1 2 8
## 92 Morocco 5.013 1 1 2 8
## 108 Palestinian Territories 4.715 1 1 2 8
## 58 Peru 5.824 1 1 2 8
## 88 Portugal 5.102 2 1 2 8
## 86 Romania 5.124 1 1 2 8
## 87 Serbia 5.123 1 1 2 8
## 45 Slovakia 5.995 1 1 2 8
## 107 Tunisia 4.739 1 1 2 8
## 76 Turkey 5.332 1 1 2 8
## 111 Ukraine 4.681 1 1 2 8