Pendahuluan

Penelitian ini bertujuan untuk mengelompokkan negara berdasarkan indikator sosial-ekonomi guna mengidentifikasi negara yang menjadi prioritas penerima bantuan dari HELP International. Analisis dilakukan menggunakan beberapa metode clustering untuk membandingkan hasil dan menentukan metode terbaik berdasarkan evaluasi metrik.

Import Library

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.2     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(cluster)
library(dbscan)
## 
## Attaching package: 'dbscan'
## 
## The following object is masked from 'package:stats':
## 
##     as.dendrogram
library(e1071)
## 
## Attaching package: 'e1071'
## 
## The following object is masked from 'package:ggplot2':
## 
##     element
library(factoextra)
## Welcome to factoextra!
## Want to learn more? See two factoextra-related books at https://www.datanovia.com/en/product/practical-guide-to-principal-component-methods-in-r/
library(meanShiftR)
library(ggplot2)

Load Dataset

Dataset yang digunakan adalah Country Data yang berisi informasi sosial-ekonomi dari berbagai negara.

data_country <- read_csv("Country-data.csv")
## Rows: 167 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): country
## dbl (9): child_mort, exports, health, imports, income, inflation, life_expec...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Preprocessing Data

Data kemudian dikonversi menjadi format data frame dan dilakukan pemisahan antara variabel identitas (nama negara) dengan variabel numerik. Nama negara dijadikan sebagai row names untuk mempermudah identifikasi hasil clustering.

Selanjutnya, dilakukan normalisasi data menggunakan metode Z-score (scale()) agar seluruh variabel memiliki skala yang sebanding dan tidak mendominasi hasil analisis.

data_country <- as.data.frame(data_country)
print(data_country)
##                            country child_mort exports health  imports income
## 1                      Afghanistan       90.2  10.000   7.58  44.9000   1610
## 2                          Albania       16.6  28.000   6.55  48.6000   9930
## 3                          Algeria       27.3  38.400   4.17  31.4000  12900
## 4                           Angola      119.0  62.300   2.85  42.9000   5900
## 5              Antigua and Barbuda       10.3  45.500   6.03  58.9000  19100
## 6                        Argentina       14.5  18.900   8.10  16.0000  18700
## 7                          Armenia       18.1  20.800   4.40  45.3000   6700
## 8                        Australia        4.8  19.800   8.73  20.9000  41400
## 9                          Austria        4.3  51.300  11.00  47.8000  43200
## 10                      Azerbaijan       39.2  54.300   5.88  20.7000  16000
## 11                         Bahamas       13.8  35.000   7.89  43.7000  22900
## 12                         Bahrain        8.6  69.500   4.97  50.9000  41100
## 13                      Bangladesh       49.4  16.000   3.52  21.8000   2440
## 14                        Barbados       14.2  39.500   7.97  48.7000  15300
## 15                         Belarus        5.5  51.400   5.61  64.5000  16200
## 16                         Belgium        4.5  76.400  10.70  74.7000  41100
## 17                          Belize       18.8  58.200   5.20  57.5000   7880
## 18                           Benin      111.0  23.800   4.10  37.2000   1820
## 19                          Bhutan       42.7  42.500   5.20  70.7000   6420
## 20                         Bolivia       46.6  41.200   4.84  34.3000   5410
## 21          Bosnia and Herzegovina        6.9  29.700  11.10  51.3000   9720
## 22                        Botswana       52.5  43.600   8.30  51.3000  13300
## 23                          Brazil       19.8  10.700   9.01  11.8000  14500
## 24                          Brunei       10.5  67.400   2.84  28.0000  80600
## 25                        Bulgaria       10.8  50.200   6.87  53.0000  15300
## 26                    Burkina Faso      116.0  19.200   6.74  29.6000   1430
## 27                         Burundi       93.6   8.920  11.60  39.2000    764
## 28                        Cambodia       44.4  54.100   5.68  59.5000   2520
## 29                        Cameroon      108.0  22.200   5.13  27.0000   2660
## 30                          Canada        5.6  29.100  11.30  31.0000  40700
## 31                      Cape Verde       26.5  32.700   4.09  61.8000   5830
## 32        Central African Republic      149.0  11.800   3.98  26.5000    888
## 33                            Chad      150.0  36.800   4.53  43.5000   1930
## 34                           Chile        8.7  37.700   7.96  31.3000  19400
## 35                           China       15.7  26.300   5.07  22.6000   9530
## 36                        Colombia       18.6  15.900   7.59  17.8000  10900
## 37                         Comoros       88.2  16.500   4.51  51.7000   1410
## 38                Congo, Dem. Rep.      116.0  41.100   7.91  49.6000    609
## 39                     Congo, Rep.       63.9  85.100   2.46  54.7000   5190
## 40                      Costa Rica       10.2  33.200  10.90  35.0000  13000
## 41                   Cote d'Ivoire      111.0  50.600   5.30  43.3000   2690
## 42                         Croatia        5.5  37.600   7.76  38.1000  20100
## 43                          Cyprus        3.6  50.200   5.97  57.5000  33900
## 44                  Czech Republic        3.4  66.000   7.88  62.9000  28300
## 45                         Denmark        4.1  50.500  11.40  43.6000  44000
## 46              Dominican Republic       34.4  22.700   6.22  33.3000  11100
## 47                         Ecuador       25.1  27.900   8.06  32.4000   9350
## 48                           Egypt       29.1  21.300   4.66  26.6000   9860
## 49                     El Salvador       19.2  26.900   6.91  46.6000   7300
## 50               Equatorial Guinea      111.0  85.800   4.48  58.9000  33700
## 51                         Eritrea       55.2   4.790   2.66  23.3000   1420
## 52                         Estonia        4.5  75.100   6.03  68.7000  22700
## 53                            Fiji       24.1  57.800   4.86  63.9000   7350
## 54                         Finland        3.0  38.700   8.95  37.4000  39800
## 55                          France        4.2  26.800  11.90  28.1000  36900
## 56                           Gabon       63.7  57.700   3.50  18.9000  15400
## 57                          Gambia       80.3  23.800   5.69  42.7000   1660
## 58                         Georgia       16.5  35.000  10.10  52.8000   6730
## 59                         Germany        4.2  42.300  11.60  37.1000  40400
## 60                           Ghana       74.7  29.500   5.22  45.9000   3060
## 61                          Greece        3.9  22.100  10.30  30.7000  28700
## 62                         Grenada       14.6  23.800   5.86  49.2000  11200
## 63                       Guatemala       35.4  25.800   6.85  36.3000   6710
## 64                          Guinea      109.0  30.300   4.93  43.2000   1190
## 65                   Guinea-Bissau      114.0  14.900   8.50  35.2000   1390
## 66                          Guyana       37.6  51.400   5.38  79.1000   5840
## 67                           Haiti      208.0  15.300   6.91  64.7000   1500
## 68                         Hungary        6.0  81.800   7.33  76.5000  22300
## 69                         Iceland        2.6  53.400   9.40  43.3000  38800
## 70                           India       58.8  22.600   4.05  27.1000   4410
## 71                       Indonesia       33.3  24.300   2.61  22.4000   8430
## 72                            Iran       19.3  24.400   5.60  19.4000  17400
## 73                            Iraq       36.9  39.400   8.41  34.1000  12700
## 74                         Ireland        4.2 103.000   9.19  86.5000  45700
## 75                          Israel        4.6  35.000   7.63  32.9000  29600
## 76                           Italy        4.0  25.200   9.53  27.2000  36200
## 77                         Jamaica       18.1  31.300   4.81  49.6000   8000
## 78                           Japan        3.2  15.000   9.49  13.6000  35800
## 79                          Jordan       21.1  48.300   8.04  69.0000   9470
## 80                      Kazakhstan       21.5  44.200   4.29  29.9000  20100
## 81                           Kenya       62.2  20.700   4.75  33.6000   2480
## 82                        Kiribati       62.7  13.300  11.30  79.9000   1730
## 83                          Kuwait       10.8  66.700   2.63  30.4000  75200
## 84                 Kyrgyz Republic       29.6  51.600   6.18  81.7000   2790
## 85                             Lao       78.9  35.400   4.47  49.3000   3980
## 86                          Latvia        7.8  53.700   6.68  55.1000  18300
## 87                         Lebanon       10.3  35.800   7.03  60.2000  16300
## 88                         Lesotho       99.7  39.400  11.10 101.0000   2380
## 89                         Liberia       89.3  19.100  11.80  92.6000    700
## 90                           Libya       16.6  65.600   3.88  42.1000  29600
## 91                       Lithuania        6.1  65.300   7.04  67.2000  21100
## 92                      Luxembourg        2.8 175.000   7.77 142.0000  91700
## 93                  Macedonia, FYR       10.4  39.800   7.09  58.1000  11400
## 94                      Madagascar       62.2  25.000   3.77  43.0000   1390
## 95                          Malawi       90.5  22.800   6.59  34.9000   1030
## 96                        Malaysia        7.9  86.900   4.39  71.0000  21100
## 97                        Maldives       13.2  77.600   6.33  65.4000  10500
## 98                            Mali      137.0  22.800   4.98  35.1000   1870
## 99                           Malta        6.8 153.000   8.65 154.0000  28300
## 100                     Mauritania       97.4  50.700   4.41  61.2000   3320
## 101                      Mauritius       15.0  51.200   6.00  62.2000  15900
## 102          Micronesia, Fed. Sts.       40.0  23.500  14.20  81.0000   3340
## 103                        Moldova       17.2  39.200  11.70  78.5000   3910
## 104                       Mongolia       26.1  46.700   5.44  56.7000   7710
## 105                     Montenegro        6.8  37.000   9.11  62.7000  14000
## 106                        Morocco       33.5  32.200   5.20  43.0000   6440
## 107                     Mozambique      101.0  31.500   5.21  46.2000    918
## 108                        Myanmar       64.4   0.109   1.97   0.0659   3720
## 109                        Namibia       56.0  47.800   6.78  60.7000   8460
## 110                          Nepal       47.0   9.580   5.25  36.4000   1990
## 111                    Netherlands        4.5  72.000  11.90  63.6000  45500
## 112                    New Zealand        6.2  30.300  10.10  28.0000  32300
## 113                          Niger      123.0  22.200   5.16  49.1000    814
## 114                        Nigeria      130.0  25.300   5.07  17.4000   5150
## 115                         Norway        3.2  39.700   9.48  28.5000  62300
## 116                           Oman       11.7  65.700   2.77  41.2000  45300
## 117                       Pakistan       92.1  13.500   2.20  19.4000   4280
## 118                         Panama       19.7  70.000   8.10  78.2000  15400
## 119                       Paraguay       24.1  55.100   5.87  51.5000   7290
## 120                           Peru       20.3  27.800   5.08  23.8000   9960
## 121                    Philippines       31.9  34.800   3.61  36.6000   5600
## 122                         Poland        6.0  40.100   7.46  42.1000  21800
## 123                       Portugal        3.9  29.900  11.00  37.4000  27200
## 124                          Qatar        9.0  62.300   1.81  23.8000 125000
## 125                        Romania       11.5  32.600   5.58  38.8000  17800
## 126                         Russia       10.0  29.200   5.08  21.1000  23100
## 127                         Rwanda       63.6  12.000  10.50  30.0000   1350
## 128                          Samoa       18.9  29.200   6.47  53.1000   5400
## 129                   Saudi Arabia       15.7  49.600   4.29  33.0000  45400
## 130                        Senegal       66.8  24.900   5.66  40.3000   2180
## 131                         Serbia        7.6  32.900  10.40  47.9000  12700
## 132                     Seychelles       14.4  93.800   3.40 108.0000  20400
## 133                   Sierra Leone      160.0  16.800  13.10  34.5000   1220
## 134                      Singapore        2.8 200.000   3.96 174.0000  72100
## 135                Slovak Republic        7.0  76.300   8.79  77.8000  25200
## 136                       Slovenia        3.2  64.300   9.41  62.9000  28700
## 137                Solomon Islands       28.1  49.300   8.55  81.2000   1780
## 138                   South Africa       53.7  28.600   8.94  27.4000  12000
## 139                    South Korea        4.1  49.400   6.93  46.2000  30400
## 140                          Spain        3.8  25.500   9.54  26.8000  32500
## 141                      Sri Lanka       11.2  19.600   2.94  26.8000   8560
## 142 St. Vincent and the Grenadines       20.7  26.900   4.47  57.1000   9920
## 143                          Sudan       76.7  19.700   6.32  17.2000   3370
## 144                       Suriname       24.1  52.500   7.01  38.4000  14200
## 145                         Sweden        3.0  46.200   9.63  40.7000  42900
## 146                    Switzerland        4.5  64.000  11.50  53.3000  55500
## 147                     Tajikistan       52.4  14.900   5.98  58.6000   2110
## 148                       Tanzania       71.9  18.700   6.01  29.1000   2090
## 149                       Thailand       14.9  66.500   3.88  60.8000  13500
## 150                    Timor-Leste       62.6   2.200   9.12  27.8000   1850
## 151                           Togo       90.3  40.200   7.65  57.3000   1210
## 152                          Tonga       17.4  12.400   5.07  60.3000   4980
## 153                        Tunisia       17.4  50.500   6.21  55.3000  10400
## 154                         Turkey       19.1  20.400   6.74  25.5000  18000
## 155                   Turkmenistan       62.0  76.300   2.50  44.5000   9940
## 156                         Uganda       81.0  17.100   9.01  28.6000   1540
## 157                        Ukraine       11.7  47.100   7.72  51.1000   7820
## 158           United Arab Emirates        8.6  77.700   3.66  63.6000  57600
## 159                 United Kingdom        5.2  28.200   9.64  30.8000  36200
## 160                  United States        7.3  12.400  17.90  15.8000  49400
## 161                        Uruguay       10.6  26.300   8.35  25.4000  17100
## 162                     Uzbekistan       36.3  31.700   5.81  28.5000   4240
## 163                        Vanuatu       29.2  46.600   5.25  52.7000   2950
## 164                      Venezuela       17.1  28.500   4.91  17.6000  16500
## 165                        Vietnam       23.3  72.000   6.84  80.2000   4490
## 166                          Yemen       56.3  30.000   5.18  34.4000   4480
## 167                         Zambia       83.1  37.000   5.89  30.9000   3280
##     inflation life_expec total_fer   gdpp
## 1       9.440       56.2      5.82    553
## 2       4.490       76.3      1.65   4090
## 3      16.100       76.5      2.89   4460
## 4      22.400       60.1      6.16   3530
## 5       1.440       76.8      2.13  12200
## 6      20.900       75.8      2.37  10300
## 7       7.770       73.3      1.69   3220
## 8       1.160       82.0      1.93  51900
## 9       0.873       80.5      1.44  46900
## 10     13.800       69.1      1.92   5840
## 11     -0.393       73.8      1.86  28000
## 12      7.440       76.0      2.16  20700
## 13      7.140       70.4      2.33    758
## 14      0.321       76.7      1.78  16000
## 15     15.100       70.4      1.49   6030
## 16      1.880       80.0      1.86  44400
## 17      1.140       71.4      2.71   4340
## 18      0.885       61.8      5.36    758
## 19      5.990       72.1      2.38   2180
## 20      8.780       71.6      3.20   1980
## 21      1.400       76.8      1.31   4610
## 22      8.920       57.1      2.88   6350
## 23      8.410       74.2      1.80  11200
## 24     16.700       77.1      1.84  35300
## 25      1.110       73.9      1.57   6840
## 26      6.810       57.9      5.87    575
## 27     12.300       57.7      6.26    231
## 28      3.120       66.1      2.88    786
## 29      1.910       57.3      5.11   1310
## 30      2.870       81.3      1.63  47400
## 31      0.505       72.5      2.67   3310
## 32      2.010       47.5      5.21    446
## 33      6.390       56.5      6.59    897
## 34      8.960       79.1      1.88  12900
## 35      6.940       74.6      1.59   4560
## 36      3.860       76.4      2.01   6250
## 37      3.870       65.9      4.75    769
## 38     20.800       57.5      6.54    334
## 39     20.700       60.4      4.95   2740
## 40      6.570       80.4      1.92   8200
## 41      5.390       56.3      5.27   1220
## 42      0.821       76.3      1.55  13500
## 43      2.010       79.9      1.42  30800
## 44     -1.430       77.5      1.51  19800
## 45      3.220       79.5      1.87  58000
## 46      5.440       74.6      2.60   5450
## 47      7.470       76.7      2.66   4660
## 48     10.100       70.5      3.19   2600
## 49      2.650       74.1      2.27   2990
## 50     24.900       60.9      5.21  17100
## 51     11.600       61.7      4.61    482
## 52      1.740       76.0      1.72  14600
## 53      4.230       65.3      2.67   3650
## 54      0.351       80.0      1.87  46200
## 55      1.050       81.4      2.03  40600
## 56     16.600       62.9      4.08   8750
## 57      4.300       65.5      5.71    562
## 58      8.550       72.8      1.92   2960
## 59      0.758       80.1      1.39  41800
## 60     16.600       62.2      4.27   1310
## 61      0.673       80.4      1.48  26900
## 62      0.480       71.3      2.24   7370
## 63      5.140       71.3      3.38   2830
## 64     16.100       58.0      5.34    648
## 65      2.970       55.6      5.05    547
## 66      5.730       65.5      2.65   3040
## 67      5.450       32.1      3.33    662
## 68      2.330       74.5      1.25  13100
## 69      5.470       82.0      2.20  41900
## 70      8.980       66.2      2.60   1350
## 71     15.300       69.9      2.48   3110
## 72     15.900       74.5      1.76   6530
## 73     16.600       67.2      4.56   4500
## 74     -3.220       80.4      2.05  48700
## 75      1.770       81.4      3.03  30600
## 76      0.319       81.7      1.46  35800
## 77      9.810       74.7      2.17   4680
## 78     -1.900       82.8      1.39  44500
## 79      8.430       75.8      3.66   3680
## 80     19.500       68.4      2.60   9070
## 81      2.090       62.8      4.37    967
## 82      1.520       60.7      3.84   1490
## 83     11.200       78.2      2.21  38500
## 84     10.000       68.5      3.10    880
## 85      9.200       63.8      3.15   1140
## 86     -0.812       73.1      1.36  11300
## 87      0.238       79.8      1.61   8860
## 88      4.150       46.5      3.30   1170
## 89      5.470       60.8      5.02    327
## 90     14.200       76.1      2.41  12100
## 91      2.380       73.2      1.50  12000
## 92      3.620       81.3      1.63 105000
## 93      2.040       74.0      1.47   4540
## 94      8.790       60.8      4.60    413
## 95     12.100       53.1      5.31    459
## 96      7.270       74.5      2.15   9070
## 97      2.880       77.9      2.23   7100
## 98      4.370       59.5      6.55    708
## 99      3.830       80.3      1.36  21100
## 100    18.900       68.2      4.98   1200
## 101     1.130       73.4      1.57   8000
## 102     3.800       65.4      3.46   2860
## 103    11.100       69.7      1.27   1630
## 104    39.200       66.2      2.64   2650
## 105     1.600       76.4      1.77   6680
## 106     0.976       73.5      2.58   2830
## 107     7.640       54.5      5.56    419
## 108     7.040       66.8      2.41    988
## 109     3.560       58.6      3.60   5190
## 110    15.100       68.3      2.61    592
## 111     0.848       80.7      1.79  50300
## 112     3.730       80.9      2.17  33700
## 113     2.550       58.8      7.49    348
## 114   104.000       60.5      5.84   2330
## 115     5.950       81.0      1.95  87800
## 116    15.600       76.1      2.90  19300
## 117    10.900       65.3      3.85   1040
## 118     2.590       77.8      2.62   8080
## 119     6.100       74.1      2.73   3230
## 120     5.710       77.9      2.54   5020
## 121     4.220       69.0      3.16   2130
## 122     1.660       76.3      1.41  12600
## 123     0.643       79.8      1.39  22500
## 124     6.980       79.5      2.07  70300
## 125     3.530       73.7      1.59   8230
## 126    14.200       69.2      1.57  10700
## 127     2.610       64.6      4.51    563
## 128     1.720       71.5      4.34   3450
## 129    17.200       75.1      2.96  19300
## 130     1.850       64.0      5.06   1000
## 131     5.880       74.7      1.40   5410
## 132    -4.210       73.4      2.17  10800
## 133    17.200       55.0      5.20    399
## 134    -0.046       82.7      1.15  46600
## 135     0.485       75.5      1.43  16600
## 136    -0.987       79.5      1.57  23400
## 137     6.810       61.7      4.24   1290
## 138     6.350       54.3      2.59   7280
## 139     3.160       80.1      1.23  22100
## 140     0.160       81.9      1.37  30700
## 141    22.800       74.4      2.20   2810
## 142     4.440       71.6      2.07   6230
## 143    19.600       66.3      4.88   1480
## 144     7.200       70.3      2.52   8300
## 145     0.991       81.5      1.98  52100
## 146     0.317       82.2      1.52  74600
## 147    12.500       69.6      3.51    738
## 148     9.250       59.3      5.43    702
## 149     4.080       76.6      1.55   5080
## 150    26.500       71.1      6.23   3600
## 151     1.180       58.7      4.87    488
## 152     3.680       69.9      3.91   3550
## 153     3.820       76.9      2.14   4140
## 154     7.010       78.2      2.15  10700
## 155     2.310       67.9      2.83   4440
## 156    10.600       56.8      6.15    595
## 157    13.400       70.4      1.44   2970
## 158    12.500       76.5      1.87  35000
## 159     1.570       80.3      1.92  38900
## 160     1.220       78.7      1.93  48400
## 161     4.910       76.4      2.08  11900
## 162    16.500       68.8      2.34   1380
## 163     2.620       63.0      3.50   2970
## 164    45.900       75.4      2.47  13500
## 165    12.100       73.1      1.95   1310
## 166    23.600       67.5      4.67   1310
## 167    14.000       52.0      5.40   1460
rownames(data_country) <- data_country$country
data_country_numeric <- data_country[, -1]
data_country_scaled <- scale(data_country_numeric)
summary(data_country_scaled)
##    child_mort         exports            health           imports       
##  Min.   :-0.8845   Min.   :-1.4957   Min.   :-1.8223   Min.   :-1.9341  
##  1st Qu.:-0.7444   1st Qu.:-0.6314   1st Qu.:-0.6901   1st Qu.:-0.6894  
##  Median :-0.4704   Median :-0.2229   Median :-0.1805   Median :-0.1483  
##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 0.5909   3rd Qu.: 0.3736   3rd Qu.: 0.6496   3rd Qu.: 0.4899  
##  Max.   : 4.2086   Max.   : 5.7964   Max.   : 4.0353   Max.   : 5.2504  
##      income          inflation         life_expec        total_fer      
##  Min.   :-0.8577   Min.   :-1.1344   Min.   :-4.3242   Min.   :-1.1877  
##  1st Qu.:-0.7153   1st Qu.:-0.5649   1st Qu.:-0.5910   1st Qu.:-0.7616  
##  Median :-0.3727   Median :-0.2263   Median : 0.2861   Median :-0.3554  
##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 0.2934   3rd Qu.: 0.2808   3rd Qu.: 0.7021   3rd Qu.: 0.6157  
##  Max.   : 5.5947   Max.   : 9.1023   Max.   : 1.3768   Max.   : 3.0003  
##       gdpp         
##  Min.   :-0.69471  
##  1st Qu.:-0.63475  
##  Median :-0.45307  
##  Mean   : 0.00000  
##  3rd Qu.: 0.05924  
##  Max.   : 5.02140

Menentukan Jumlah Cluster Optimal

Penentuan jumlah cluster optimal dilakukan menggunakan metode Silhouette Analysis. Visualisasi menunjukkan bahwa nilai terbaik diperoleh pada k = 2, sehingga analisis selanjutnya menggunakan dua cluster.

fviz_nbclust(data_country_scaled, kmeans, method = "silhouette")

fviz_nbclust(data_country_scaled, pam, method = "silhouette")

## K-Means Clustering Metode K-Means diterapkan dengan jumlah cluster sebanyak 2. Algoritma ini bekerja dengan membagi data ke dalam kelompok berdasarkan jarak terdekat terhadap centroid. Hasil clustering menunjukkan pembagian negara ke dalam dua kelompok utama.

set.seed(123)
kmeans_data <- kmeans(data_country_scaled, centers = 2, nstart = 25)
print(kmeans_data)
## K-means clustering with 2 clusters of sizes 99, 68
## 
## Cluster means:
##   child_mort    exports     health     imports     income  inflation life_expec
## 1 -0.6473874  0.2733858  0.1814275  0.09215345  0.4602372 -0.2155284  0.6677315
## 2  0.9425200 -0.3980176 -0.2641371 -0.13416458 -0.6700512  0.3137840 -0.9721385
##    total_fer       gdpp
## 1 -0.6650953  0.4115852
## 2  0.9683006 -0.5992197
## 
## Clustering vector:
##                    Afghanistan                        Albania 
##                              2                              1 
##                        Algeria                         Angola 
##                              1                              2 
##            Antigua and Barbuda                      Argentina 
##                              1                              1 
##                        Armenia                      Australia 
##                              1                              1 
##                        Austria                     Azerbaijan 
##                              1                              1 
##                        Bahamas                        Bahrain 
##                              1                              1 
##                     Bangladesh                       Barbados 
##                              2                              1 
##                        Belarus                        Belgium 
##                              1                              1 
##                         Belize                          Benin 
##                              1                              2 
##                         Bhutan                        Bolivia 
##                              1                              2 
##         Bosnia and Herzegovina                       Botswana 
##                              1                              2 
##                         Brazil                         Brunei 
##                              1                              1 
##                       Bulgaria                   Burkina Faso 
##                              1                              2 
##                        Burundi                       Cambodia 
##                              2                              2 
##                       Cameroon                         Canada 
##                              2                              1 
##                     Cape Verde       Central African Republic 
##                              1                              2 
##                           Chad                          Chile 
##                              2                              1 
##                          China                       Colombia 
##                              1                              1 
##                        Comoros               Congo, Dem. Rep. 
##                              2                              2 
##                    Congo, Rep.                     Costa Rica 
##                              2                              1 
##                  Cote d'Ivoire                        Croatia 
##                              2                              1 
##                         Cyprus                 Czech Republic 
##                              1                              1 
##                        Denmark             Dominican Republic 
##                              1                              1 
##                        Ecuador                          Egypt 
##                              1                              2 
##                    El Salvador              Equatorial Guinea 
##                              1                              2 
##                        Eritrea                        Estonia 
##                              2                              1 
##                           Fiji                        Finland 
##                              1                              1 
##                         France                          Gabon 
##                              1                              2 
##                         Gambia                        Georgia 
##                              2                              1 
##                        Germany                          Ghana 
##                              1                              2 
##                         Greece                        Grenada 
##                              1                              1 
##                      Guatemala                         Guinea 
##                              2                              2 
##                  Guinea-Bissau                         Guyana 
##                              2                              2 
##                          Haiti                        Hungary 
##                              2                              1 
##                        Iceland                          India 
##                              1                              2 
##                      Indonesia                           Iran 
##                              2                              1 
##                           Iraq                        Ireland 
##                              2                              1 
##                         Israel                          Italy 
##                              1                              1 
##                        Jamaica                          Japan 
##                              1                              1 
##                         Jordan                     Kazakhstan 
##                              1                              1 
##                          Kenya                       Kiribati 
##                              2                              2 
##                         Kuwait                Kyrgyz Republic 
##                              1                              2 
##                            Lao                         Latvia 
##                              2                              1 
##                        Lebanon                        Lesotho 
##                              1                              2 
##                        Liberia                          Libya 
##                              2                              1 
##                      Lithuania                     Luxembourg 
##                              1                              1 
##                 Macedonia, FYR                     Madagascar 
##                              1                              2 
##                         Malawi                       Malaysia 
##                              2                              1 
##                       Maldives                           Mali 
##                              1                              2 
##                          Malta                     Mauritania 
##                              1                              2 
##                      Mauritius          Micronesia, Fed. Sts. 
##                              1                              2 
##                        Moldova                       Mongolia 
##                              1                              2 
##                     Montenegro                        Morocco 
##                              1                              1 
##                     Mozambique                        Myanmar 
##                              2                              2 
##                        Namibia                          Nepal 
##                              2                              2 
##                    Netherlands                    New Zealand 
##                              1                              1 
##                          Niger                        Nigeria 
##                              2                              2 
##                         Norway                           Oman 
##                              1                              1 
##                       Pakistan                         Panama 
##                              2                              1 
##                       Paraguay                           Peru 
##                              1                              1 
##                    Philippines                         Poland 
##                              2                              1 
##                       Portugal                          Qatar 
##                              1                              1 
##                        Romania                         Russia 
##                              1                              1 
##                         Rwanda                          Samoa 
##                              2                              2 
##                   Saudi Arabia                        Senegal 
##                              1                              2 
##                         Serbia                     Seychelles 
##                              1                              1 
##                   Sierra Leone                      Singapore 
##                              2                              1 
##                Slovak Republic                       Slovenia 
##                              1                              1 
##                Solomon Islands                   South Africa 
##                              2                              2 
##                    South Korea                          Spain 
##                              1                              1 
##                      Sri Lanka St. Vincent and the Grenadines 
##                              1                              1 
##                          Sudan                       Suriname 
##                              2                              1 
##                         Sweden                    Switzerland 
##                              1                              1 
##                     Tajikistan                       Tanzania 
##                              2                              2 
##                       Thailand                    Timor-Leste 
##                              1                              2 
##                           Togo                          Tonga 
##                              2                              2 
##                        Tunisia                         Turkey 
##                              1                              1 
##                   Turkmenistan                         Uganda 
##                              2                              2 
##                        Ukraine           United Arab Emirates 
##                              1                              1 
##                 United Kingdom                  United States 
##                              1                              1 
##                        Uruguay                     Uzbekistan 
##                              1                              2 
##                        Vanuatu                      Venezuela 
##                              2                              1 
##                        Vietnam                          Yemen 
##                              1                              2 
##                         Zambia 
##                              2 
## 
## Within cluster sum of squares by cluster:
## [1] 643.3747 400.5512
##  (between_SS / total_SS =  30.1 %)
## 
## Available components:
## 
## [1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
## [6] "betweenss"    "size"         "iter"         "ifault"

K-Median Clustering

Sebagai pembanding, digunakan metode K-Median (PAM) yang lebih robust terhadap outlier. Hasil yang diperoleh menunjukkan pola pengelompokan yang serupa dengan K-Means.

kmedian_data <- pam(data_country_scaled, k = 2)
print(kmedian_data)
## Medoids:
##         ID child_mort     exports     health     imports     income  inflation
## Ghana   60  0.9033202 -0.42349963 -0.5809185 -0.04090177 -0.7306069  0.8342082
## Poland 122 -0.8001715 -0.03680781  0.2345648 -0.19786437  0.2414823 -0.5791319
##        life_expec  total_fer        gdpp
## Ghana  -0.9395623  0.8732953 -0.63584175
## Poland  0.6459238 -1.0159306 -0.01986805
## Clustering vector:
##                    Afghanistan                        Albania 
##                              1                              2 
##                        Algeria                         Angola 
##                              2                              1 
##            Antigua and Barbuda                      Argentina 
##                              2                              2 
##                        Armenia                      Australia 
##                              2                              2 
##                        Austria                     Azerbaijan 
##                              2                              2 
##                        Bahamas                        Bahrain 
##                              2                              2 
##                     Bangladesh                       Barbados 
##                              1                              2 
##                        Belarus                        Belgium 
##                              2                              2 
##                         Belize                          Benin 
##                              2                              1 
##                         Bhutan                        Bolivia 
##                              2                              1 
##         Bosnia and Herzegovina                       Botswana 
##                              2                              1 
##                         Brazil                         Brunei 
##                              2                              2 
##                       Bulgaria                   Burkina Faso 
##                              2                              1 
##                        Burundi                       Cambodia 
##                              1                              1 
##                       Cameroon                         Canada 
##                              1                              2 
##                     Cape Verde       Central African Republic 
##                              2                              1 
##                           Chad                          Chile 
##                              1                              2 
##                          China                       Colombia 
##                              2                              2 
##                        Comoros               Congo, Dem. Rep. 
##                              1                              1 
##                    Congo, Rep.                     Costa Rica 
##                              1                              2 
##                  Cote d'Ivoire                        Croatia 
##                              1                              2 
##                         Cyprus                 Czech Republic 
##                              2                              2 
##                        Denmark             Dominican Republic 
##                              2                              2 
##                        Ecuador                          Egypt 
##                              2                              1 
##                    El Salvador              Equatorial Guinea 
##                              2                              1 
##                        Eritrea                        Estonia 
##                              1                              2 
##                           Fiji                        Finland 
##                              2                              2 
##                         France                          Gabon 
##                              2                              1 
##                         Gambia                        Georgia 
##                              1                              2 
##                        Germany                          Ghana 
##                              2                              1 
##                         Greece                        Grenada 
##                              2                              2 
##                      Guatemala                         Guinea 
##                              2                              1 
##                  Guinea-Bissau                         Guyana 
##                              1                              1 
##                          Haiti                        Hungary 
##                              1                              2 
##                        Iceland                          India 
##                              2                              1 
##                      Indonesia                           Iran 
##                              1                              2 
##                           Iraq                        Ireland 
##                              1                              2 
##                         Israel                          Italy 
##                              2                              2 
##                        Jamaica                          Japan 
##                              2                              2 
##                         Jordan                     Kazakhstan 
##                              2                              1 
##                          Kenya                       Kiribati 
##                              1                              1 
##                         Kuwait                Kyrgyz Republic 
##                              2                              1 
##                            Lao                         Latvia 
##                              1                              2 
##                        Lebanon                        Lesotho 
##                              2                              1 
##                        Liberia                          Libya 
##                              1                              2 
##                      Lithuania                     Luxembourg 
##                              2                              2 
##                 Macedonia, FYR                     Madagascar 
##                              2                              1 
##                         Malawi                       Malaysia 
##                              1                              2 
##                       Maldives                           Mali 
##                              2                              1 
##                          Malta                     Mauritania 
##                              2                              1 
##                      Mauritius          Micronesia, Fed. Sts. 
##                              2                              2 
##                        Moldova                       Mongolia 
##                              2                              1 
##                     Montenegro                        Morocco 
##                              2                              2 
##                     Mozambique                        Myanmar 
##                              1                              1 
##                        Namibia                          Nepal 
##                              1                              1 
##                    Netherlands                    New Zealand 
##                              2                              2 
##                          Niger                        Nigeria 
##                              1                              1 
##                         Norway                           Oman 
##                              2                              2 
##                       Pakistan                         Panama 
##                              1                              2 
##                       Paraguay                           Peru 
##                              2                              2 
##                    Philippines                         Poland 
##                              1                              2 
##                       Portugal                          Qatar 
##                              2                              2 
##                        Romania                         Russia 
##                              2                              2 
##                         Rwanda                          Samoa 
##                              1                              1 
##                   Saudi Arabia                        Senegal 
##                              2                              1 
##                         Serbia                     Seychelles 
##                              2                              2 
##                   Sierra Leone                      Singapore 
##                              1                              2 
##                Slovak Republic                       Slovenia 
##                              2                              2 
##                Solomon Islands                   South Africa 
##                              1                              1 
##                    South Korea                          Spain 
##                              2                              2 
##                      Sri Lanka St. Vincent and the Grenadines 
##                              1                              2 
##                          Sudan                       Suriname 
##                              1                              2 
##                         Sweden                    Switzerland 
##                              2                              2 
##                     Tajikistan                       Tanzania 
##                              1                              1 
##                       Thailand                    Timor-Leste 
##                              2                              1 
##                           Togo                          Tonga 
##                              1                              1 
##                        Tunisia                         Turkey 
##                              2                              2 
##                   Turkmenistan                         Uganda 
##                              1                              1 
##                        Ukraine           United Arab Emirates 
##                              2                              2 
##                 United Kingdom                  United States 
##                              2                              2 
##                        Uruguay                     Uzbekistan 
##                              2                              1 
##                        Vanuatu                      Venezuela 
##                              1                              1 
##                        Vietnam                          Yemen 
##                              2                              1 
##                         Zambia 
##                              1 
## Objective function:
##    build     swap 
## 2.320291 2.251688 
## 
## Available components:
##  [1] "medoids"    "id.med"     "clustering" "objective"  "isolation" 
##  [6] "clusinfo"   "silinfo"    "diss"       "call"       "data"

Fuzzy C-Means Clustering

Metode Fuzzy C-Means digunakan untuk memberikan derajat keanggotaan pada setiap data terhadap masing-masing cluster. Dengan pendekatan ini, suatu negara dapat memiliki keanggotaan pada lebih dari satu cluster.

set.seed(123)
fcm_data <- cmeans(data_country_scaled, centers = 2, m = 2)
print(fcm_data)
## Fuzzy c-means clustering with 2 clusters
## 
## Cluster centers:
##   child_mort    exports     health     imports     income  inflation life_expec
## 1 -0.5683300  0.1976719  0.2653711  0.07641437  0.3813327 -0.2499684  0.5876800
## 2  0.7232094 -0.2872941 -0.2896684 -0.13470215 -0.4894780  0.2141617 -0.7270828
##    total_fer       gdpp
## 1 -0.5962277  0.3687191
## 2  0.7702226 -0.4485756
## 
## Memberships:
##                                         1          2
## Afghanistan                    0.15850014 0.84149986
## Albania                        0.76889877 0.23110123
## Algeria                        0.50482100 0.49517900
## Angola                         0.23224422 0.76775578
## Antigua and Barbuda            0.89523318 0.10476682
## Argentina                      0.60403123 0.39596877
## Armenia                        0.58518643 0.41481357
## Australia                      0.74981910 0.25018090
## Austria                        0.80308252 0.19691748
## Azerbaijan                     0.53179203 0.46820797
## Bahamas                        0.91836173 0.08163827
## Bahrain                        0.82509870 0.17490130
## Bangladesh                     0.34662206 0.65337794
## Barbados                       0.93019923 0.06980077
## Belarus                        0.70465020 0.29534980
## Belgium                        0.77773814 0.22226186
## Belize                         0.61677373 0.38322627
## Benin                          0.16204187 0.83795813
## Bhutan                         0.50425421 0.49574579
## Bolivia                        0.27411054 0.72588946
## Bosnia and Herzegovina         0.76110979 0.23889021
## Botswana                       0.26928669 0.73071331
## Brazil                         0.64120575 0.35879425
## Brunei                         0.64909077 0.35090923
## Bulgaria                       0.86921112 0.13078888
## Burkina Faso                   0.16721943 0.83278057
## Burundi                        0.26138187 0.73861813
## Cambodia                       0.33690166 0.66309834
## Cameroon                       0.15802500 0.84197500
## Canada                         0.77235144 0.22764856
## Cape Verde                     0.51530601 0.48469399
## Central African Republic       0.24565029 0.75434971
## Chad                           0.22150274 0.77849726
## Chile                          0.87976343 0.12023657
## China                          0.63467330 0.36532670
## Colombia                       0.65690648 0.34309352
## Comoros                        0.12244638 0.87755362
## Congo, Dem. Rep.               0.20962888 0.79037112
## Congo, Rep.                    0.28430593 0.71569407
## Costa Rica                     0.77914235 0.22085765
## Cote d'Ivoire                  0.15437322 0.84562678
## Croatia                        0.91741445 0.08258555
## Cyprus                         0.89516645 0.10483355
## Czech Republic                 0.89619292 0.10380708
## Denmark                        0.75892291 0.24107709
## Dominican Republic             0.55900458 0.44099542
## Ecuador                        0.65998495 0.34001505
## Egypt                          0.33359426 0.66640574
## El Salvador                    0.67610179 0.32389821
## Equatorial Guinea              0.34318597 0.65681403
## Eritrea                        0.19060434 0.80939566
## Estonia                        0.83034040 0.16965960
## Fiji                           0.46472596 0.53527404
## Finland                        0.82441849 0.17558151
## France                         0.76673121 0.23326879
## Gabon                          0.23155373 0.76844627
## Gambia                         0.11873546 0.88126454
## Georgia                        0.70259905 0.29740095
## Germany                        0.80023989 0.19976011
## Ghana                          0.05711118 0.94288882
## Greece                         0.82482682 0.17517318
## Grenada                        0.66825277 0.33174723
## Guatemala                      0.34120256 0.65879744
## Guinea                         0.13004416 0.86995584
## Guinea-Bissau                  0.19219182 0.80780818
## Guyana                         0.42784407 0.57215593
## Haiti                          0.34186150 0.65813850
## Hungary                        0.79570998 0.20429002
## Iceland                        0.84372701 0.15627299
## India                          0.22696181 0.77303819
## Indonesia                      0.37713655 0.62286345
## Iran                           0.61221839 0.38778161
## Iraq                           0.24558335 0.75441665
## Ireland                        0.71803709 0.28196291
## Israel                         0.84661451 0.15338549
## Italy                          0.81677854 0.18322146
## Jamaica                        0.62255053 0.37744947
## Japan                          0.74610222 0.25389778
## Jordan                         0.60339320 0.39660680
## Kazakhstan                     0.47857838 0.52142162
## Kenya                          0.11260012 0.88739988
## Kiribati                       0.36117486 0.63882514
## Kuwait                         0.66333289 0.33666711
## Kyrgyz Republic                0.43647635 0.56352365
## Lao                            0.09985974 0.90014026
## Latvia                         0.88065502 0.11934498
## Lebanon                        0.86768564 0.13231436
## Lesotho                        0.36795287 0.63204713
## Liberia                        0.33917811 0.66082189
## Libya                          0.71054014 0.28945986
## Lithuania                      0.85958830 0.14041170
## Luxembourg                     0.58881185 0.41118815
## Macedonia, FYR                 0.81723674 0.18276326
## Madagascar                     0.08886444 0.91113556
## Malawi                         0.13767441 0.86232559
## Malaysia                       0.70180854 0.29819146
## Maldives                       0.75939907 0.24060093
## Mali                           0.20608404 0.79391596
## Malta                          0.59947107 0.40052893
## Mauritania                     0.18269410 0.81730590
## Mauritius                      0.82729923 0.17270077
## Micronesia, Fed. Sts.          0.48883802 0.51116198
## Moldova                        0.62950460 0.37049540
## Mongolia                       0.42117462 0.57882538
## Montenegro                     0.83872159 0.16127841
## Morocco                        0.52590818 0.47409182
## Mozambique                     0.13831507 0.86168493
## Myanmar                        0.34684425 0.65315575
## Namibia                        0.19516516 0.80483484
## Nepal                          0.26614938 0.73385062
## Netherlands                    0.76035048 0.23964952
## New Zealand                    0.82516070 0.17483930
## Niger                          0.22745639 0.77254361
## Nigeria                        0.43430663 0.56569337
## Norway                         0.66807395 0.33192605
## Oman                           0.66182286 0.33817714
## Pakistan                       0.20255140 0.79744860
## Panama                         0.75796218 0.24203782
## Paraguay                       0.63505560 0.36494440
## Peru                           0.61159936 0.38840064
## Philippines                    0.32036520 0.67963480
## Poland                         0.93386866 0.06613134
## Portugal                       0.83925155 0.16074845
## Qatar                          0.59922036 0.40077964
## Romania                        0.80263561 0.19736439
## Russia                         0.63036840 0.36963160
## Rwanda                         0.27108988 0.72891012
## Samoa                          0.37566494 0.62433506
## Saudi Arabia                   0.67227288 0.32772712
## Senegal                        0.10127453 0.89872547
## Serbia                         0.79065368 0.20934632
## Seychelles                     0.61394559 0.38605441
## Sierra Leone                   0.31228889 0.68771111
## Singapore                      0.57706991 0.42293009
## Slovak Republic                0.81721728 0.18278272
## Slovenia                       0.88255790 0.11744210
## Solomon Islands                0.34848944 0.65151056
## South Africa                   0.30975901 0.69024099
## South Korea                    0.93839639 0.06160361
## Spain                          0.82750313 0.17249687
## Sri Lanka                      0.48198524 0.51801476
## St. Vincent and the Grenadines 0.59994630 0.40005370
## Sudan                          0.16378063 0.83621937
## Suriname                       0.70780702 0.29219298
## Sweden                         0.79662293 0.20337707
## Switzerland                    0.70854716 0.29145284
## Tajikistan                     0.19542315 0.80457685
## Tanzania                       0.10931885 0.89068115
## Thailand                       0.72330004 0.27669996
## Timor-Leste                    0.29627257 0.70372743
## Togo                           0.15854521 0.84145479
## Tonga                          0.35741854 0.64258146
## Tunisia                        0.79528549 0.20471451
## Turkey                         0.74432773 0.25567227
## Turkmenistan                   0.40175065 0.59824935
## Uganda                         0.19342658 0.80657342
## Ukraine                        0.69927941 0.30072059
## United Arab Emirates           0.71619058 0.28380942
## United Kingdom                 0.82261686 0.17738314
## United States                  0.63707380 0.36292620
## Uruguay                        0.80100038 0.19899962
## Uzbekistan                     0.35646881 0.64353119
## Vanuatu                        0.26002633 0.73997367
## Venezuela                      0.49163266 0.50836734
## Vietnam                        0.62375875 0.37624125
## Yemen                          0.16780894 0.83219106
## Zambia                         0.14700379 0.85299621
## 
## Closest hard clustering:
##                    Afghanistan                        Albania 
##                              2                              1 
##                        Algeria                         Angola 
##                              1                              2 
##            Antigua and Barbuda                      Argentina 
##                              1                              1 
##                        Armenia                      Australia 
##                              1                              1 
##                        Austria                     Azerbaijan 
##                              1                              1 
##                        Bahamas                        Bahrain 
##                              1                              1 
##                     Bangladesh                       Barbados 
##                              2                              1 
##                        Belarus                        Belgium 
##                              1                              1 
##                         Belize                          Benin 
##                              1                              2 
##                         Bhutan                        Bolivia 
##                              1                              2 
##         Bosnia and Herzegovina                       Botswana 
##                              1                              2 
##                         Brazil                         Brunei 
##                              1                              1 
##                       Bulgaria                   Burkina Faso 
##                              1                              2 
##                        Burundi                       Cambodia 
##                              2                              2 
##                       Cameroon                         Canada 
##                              2                              1 
##                     Cape Verde       Central African Republic 
##                              1                              2 
##                           Chad                          Chile 
##                              2                              1 
##                          China                       Colombia 
##                              1                              1 
##                        Comoros               Congo, Dem. Rep. 
##                              2                              2 
##                    Congo, Rep.                     Costa Rica 
##                              2                              1 
##                  Cote d'Ivoire                        Croatia 
##                              2                              1 
##                         Cyprus                 Czech Republic 
##                              1                              1 
##                        Denmark             Dominican Republic 
##                              1                              1 
##                        Ecuador                          Egypt 
##                              1                              2 
##                    El Salvador              Equatorial Guinea 
##                              1                              2 
##                        Eritrea                        Estonia 
##                              2                              1 
##                           Fiji                        Finland 
##                              2                              1 
##                         France                          Gabon 
##                              1                              2 
##                         Gambia                        Georgia 
##                              2                              1 
##                        Germany                          Ghana 
##                              1                              2 
##                         Greece                        Grenada 
##                              1                              1 
##                      Guatemala                         Guinea 
##                              2                              2 
##                  Guinea-Bissau                         Guyana 
##                              2                              2 
##                          Haiti                        Hungary 
##                              2                              1 
##                        Iceland                          India 
##                              1                              2 
##                      Indonesia                           Iran 
##                              2                              1 
##                           Iraq                        Ireland 
##                              2                              1 
##                         Israel                          Italy 
##                              1                              1 
##                        Jamaica                          Japan 
##                              1                              1 
##                         Jordan                     Kazakhstan 
##                              1                              2 
##                          Kenya                       Kiribati 
##                              2                              2 
##                         Kuwait                Kyrgyz Republic 
##                              1                              2 
##                            Lao                         Latvia 
##                              2                              1 
##                        Lebanon                        Lesotho 
##                              1                              2 
##                        Liberia                          Libya 
##                              2                              1 
##                      Lithuania                     Luxembourg 
##                              1                              1 
##                 Macedonia, FYR                     Madagascar 
##                              1                              2 
##                         Malawi                       Malaysia 
##                              2                              1 
##                       Maldives                           Mali 
##                              1                              2 
##                          Malta                     Mauritania 
##                              1                              2 
##                      Mauritius          Micronesia, Fed. Sts. 
##                              1                              2 
##                        Moldova                       Mongolia 
##                              1                              2 
##                     Montenegro                        Morocco 
##                              1                              1 
##                     Mozambique                        Myanmar 
##                              2                              2 
##                        Namibia                          Nepal 
##                              2                              2 
##                    Netherlands                    New Zealand 
##                              1                              1 
##                          Niger                        Nigeria 
##                              2                              2 
##                         Norway                           Oman 
##                              1                              1 
##                       Pakistan                         Panama 
##                              2                              1 
##                       Paraguay                           Peru 
##                              1                              1 
##                    Philippines                         Poland 
##                              2                              1 
##                       Portugal                          Qatar 
##                              1                              1 
##                        Romania                         Russia 
##                              1                              1 
##                         Rwanda                          Samoa 
##                              2                              2 
##                   Saudi Arabia                        Senegal 
##                              1                              2 
##                         Serbia                     Seychelles 
##                              1                              1 
##                   Sierra Leone                      Singapore 
##                              2                              1 
##                Slovak Republic                       Slovenia 
##                              1                              1 
##                Solomon Islands                   South Africa 
##                              2                              2 
##                    South Korea                          Spain 
##                              1                              1 
##                      Sri Lanka St. Vincent and the Grenadines 
##                              2                              1 
##                          Sudan                       Suriname 
##                              2                              1 
##                         Sweden                    Switzerland 
##                              1                              1 
##                     Tajikistan                       Tanzania 
##                              2                              2 
##                       Thailand                    Timor-Leste 
##                              1                              2 
##                           Togo                          Tonga 
##                              2                              2 
##                        Tunisia                         Turkey 
##                              1                              1 
##                   Turkmenistan                         Uganda 
##                              2                              2 
##                        Ukraine           United Arab Emirates 
##                              1                              1 
##                 United Kingdom                  United States 
##                              1                              1 
##                        Uruguay                     Uzbekistan 
##                              1                              2 
##                        Vanuatu                      Venezuela 
##                              2                              2 
##                        Vietnam                          Yemen 
##                              1                              2 
##                         Zambia 
##                              2 
## 
## Available components:
## [1] "centers"     "size"        "cluster"     "membership"  "iter"       
## [6] "withinerror" "call"

DBSCAN Clustering

Metode DBSCAN diterapkan untuk mengidentifikasi cluster berdasarkan kepadatan data serta mendeteksi outlier. Berdasarkan hasil analisis, ditemukan satu cluster utama serta beberapa data yang dikategorikan sebagai noise.

kNNdistplot(data_country_scaled, k = 5)

dbscan_data3 <- dbscan(data_country_scaled, eps = 2.2, minPts = 5)
print(dbscan_data3)
## DBSCAN clustering for 167 objects.
## Parameters: eps = 2.2, minPts = 5
## Using euclidean distances and borderpoints = TRUE
## The clustering contains 1 cluster(s) and 10 noise points.
## 
##   0   1 
##  10 157 
## 
## Available fields: cluster, eps, minPts, metric, borderPoints
rownames(data_country_scaled)[dbscan_data3$cluster == 0]
##  [1] "Haiti"         "Lesotho"       "Luxembourg"    "Malta"        
##  [5] "Mongolia"      "Nigeria"       "Qatar"         "Singapore"    
##  [9] "United States" "Venezuela"
fviz_cluster(dbscan_data3, data = data_country_scaled, geom = "point", ellipse = TRUE,main = "DBSCAN: One Major Cluster & 10 Outliers") + theme_minimal()

Mean Shift Clustering

Metode Mean Shift digunakan untuk mengidentifikasi cluster tanpa menentukan jumlah cluster di awal. Hasil menunjukkan terbentuknya beberapa cluster dengan ukuran yang bervariasi, mencerminkan kompleksitas data.

ms_data <- meanShift(data_country_scaled, nNeighbor = 10)
ms_labels <- ms_data$assignment
table(ms_data$assignment)
## 
##  1  2  3  4  5  6  7  8  9 10 11 
## 30 72 29  6  4  3 10  5  3  3  2

Evaluasi Model Clustering

Evaluasi dilakukan menggunakan Average Silhouette Score untuk mengukur kualitas hasil clustering. Semakin tinggi nilai silhouette, semakin baik pemisahan antar cluster.

Hasil evaluasi menunjukkan bahwa metode K-Means memiliki nilai tertinggi dibandingkan metode lainnya, sehingga dianggap sebagai metode terbaik untuk dataset ini.

avg_km <- mean(silhouette(kmeans_data$cluster, dist(data_country_scaled))[, 3])
avg_kmed <- mean(silhouette(kmedian_data$clustering, dist(data_country_scaled))[, 3])
avg_fcm <- mean(silhouette(fcm_data$cluster, dist(data_country_scaled))[, 3])
avg_ms <- mean(silhouette(ms_data$assignment, dist(data_country_scaled))[, 3])
eval_metrik <- data.frame(Model = c("K-Means", "K-Medians", "Fuzzy C-Means", "Mean Shift"),Silhouette = c(avg_km, avg_kmed, avg_fcm, avg_ms))
print(eval_metrik)
##           Model Silhouette
## 1       K-Means 0.28735669
## 2     K-Medians 0.28463921
## 3 Fuzzy C-Means 0.28382908
## 4    Mean Shift 0.08256764

Visualisasi Perbandingan Model

ggplot(eval_metrik, aes(x = reorder(Model, -Silhouette), y = Silhouette)) + geom_bar(stat = "identity", width = 0.6, fill = "slategray") + geom_text(aes(label = round(Silhouette, 3)), vjust = -0.5, size = 4, fontface = "bold") + labs(
title = "Evaluasi Performa Model Clustering",
subtitle = "Berdasarkan Average Silhouette Score",
x = "Algoritma",
y = "Silhouette Score") + theme_minimal() + theme(panel.grid.major.x = element_blank(), plot.title = element_text(face = "bold", size = 14))

Visualisasi K-Means

Visualisasi cluster menggunakan metode K-Means menunjukkan pemisahan yang cukup jelas antara dua kelompok negara. Cluster pertama merepresentasikan negara dengan kondisi sosial-ekonomi yang lebih baik, sedangkan cluster kedua menunjukkan negara dengan kondisi yang lebih rendah.

fviz_cluster(kmeans_data, data = data_country_scaled,
                           palette = c("#E7B800","#2E9FDF"), 
                           geom = "point",
                          ellipse.type = "convex", 
                          ggtheme = theme_minimal(),
                         main = "Visualisasi Klasterisasi Negara (K-Means)")

rownames(data_country_scaled)[kmeans_data$cluster==2]
##  [1] "Afghanistan"              "Angola"                  
##  [3] "Bangladesh"               "Benin"                   
##  [5] "Bolivia"                  "Botswana"                
##  [7] "Burkina Faso"             "Burundi"                 
##  [9] "Cambodia"                 "Cameroon"                
## [11] "Central African Republic" "Chad"                    
## [13] "Comoros"                  "Congo, Dem. Rep."        
## [15] "Congo, Rep."              "Cote d'Ivoire"           
## [17] "Egypt"                    "Equatorial Guinea"       
## [19] "Eritrea"                  "Gabon"                   
## [21] "Gambia"                   "Ghana"                   
## [23] "Guatemala"                "Guinea"                  
## [25] "Guinea-Bissau"            "Guyana"                  
## [27] "Haiti"                    "India"                   
## [29] "Indonesia"                "Iraq"                    
## [31] "Kenya"                    "Kiribati"                
## [33] "Kyrgyz Republic"          "Lao"                     
## [35] "Lesotho"                  "Liberia"                 
## [37] "Madagascar"               "Malawi"                  
## [39] "Mali"                     "Mauritania"              
## [41] "Micronesia, Fed. Sts."    "Mongolia"                
## [43] "Mozambique"               "Myanmar"                 
## [45] "Namibia"                  "Nepal"                   
## [47] "Niger"                    "Nigeria"                 
## [49] "Pakistan"                 "Philippines"             
## [51] "Rwanda"                   "Samoa"                   
## [53] "Senegal"                  "Sierra Leone"            
## [55] "Solomon Islands"          "South Africa"            
## [57] "Sudan"                    "Tajikistan"              
## [59] "Tanzania"                 "Timor-Leste"             
## [61] "Togo"                     "Tonga"                   
## [63] "Turkmenistan"             "Uganda"                  
## [65] "Uzbekistan"               "Vanuatu"                 
## [67] "Yemen"                    "Zambia"

Kesimpulan

Dari lima metode clustering yang digunakan, K-Means memberikan performa terbaik berdasarkan nilai Silhouette Score tertinggi dan menghasilkan dua cluster utama. Cluster pertama terdiri dari 99 negara dengan kondisi ekonomi yang lebih baik, sedangkan cluster kedua berisi 68 negara dengan kondisi yang lebih rendah. Negara pada cluster kedua direkomendasikan sebagai prioritas penerima bantuan karena memiliki indikator kesejahteraan yang lebih rendah.