Machine Learning Technique: CLustering Method
Data
## Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
##
## 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
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.4 ✔ tibble 3.2.1
## ✔ purrr 1.0.4 ✔ tidyr 1.3.1
## ✔ readr 2.1.5
## ── 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
## Loading required package: viridisLite
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
## Linking to liblwgeom 3.0.0beta1 r16016, GEOS 3.11.0, PROJ 9.1.0
## Warning in fun(libname, pkgname): GEOS versions differ: lwgeom has 3.11.0 sf
## has 3.13.0
## Warning in fun(libname, pkgname): PROJ versions differ: lwgeom has 9.1.0 sf has
## 9.5.1
##
## Attaching package: 'lwgeom'
##
## The following object is masked from 'package:sf':
##
## st_perimeter
##
## Attaching package: 'rnaturalearthdata'
##
## The following object is masked from 'package:rnaturalearth':
##
## countries110
## corrplot 0.95 loaded
## Loading required package: carData
##
## Attaching package: 'car'
##
## The following object is masked from 'package:purrr':
##
## some
##
## The following object is masked from 'package:dplyr':
##
## recode
## Loading required package: terra
## terra 1.8.29
##
## Attaching package: 'terra'
##
## The following object is masked from 'package:tidyr':
##
## extract
##
##
## Attaching package: 'usdm'
##
## The following object is masked from 'package:car':
##
## vif
##
## Attaching package: 'psych'
##
## The following objects are masked from 'package:terra':
##
## describe, distance, rescale
##
## The following object is masked from 'package:car':
##
## logit
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
## Loading required package: cluster
## Loading required package: MASS
##
## Attaching package: 'MASS'
##
## The following object is masked from 'package:terra':
##
## area
##
## The following object is masked from 'package:dplyr':
##
## select
## Rows: 26 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Country
## dbl (9): Agr, Min, Man, PS, Con, SI, Fin, SPS, TC
##
## ℹ 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.
## # A tibble: 26 × 10
## Country Agr Min Man PS Con SI Fin SPS TC
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Belgium 3.3 0.9 27.6 0.9 8.2 19.1 6.2 26.6 7.2
## 2 Denmark 9.2 0.1 21.8 0.6 8.3 14.6 6.5 32.2 7.1
## 3 France 10.8 0.8 27.5 0.9 8.9 16.8 6 22.6 5.7
## 4 W. Germany 6.7 1.3 35.8 0.9 7.3 14.4 5 22.3 6.1
## 5 Ireland 23.2 1 20.7 1.3 7.5 16.8 2.8 20.8 6.1
## 6 Italy 15.9 0.6 27.6 0.5 10 18.1 1.6 20.1 5.7
## 7 Luxembourg 7.7 3.1 30.8 0.8 9.2 18.5 4.6 19.2 6.2
## 8 Netherlands 6.3 0.1 22.5 1 9.9 18 6.8 28.5 6.8
## 9 United Kingdom 2.7 1.4 30.2 1.4 6.9 16.9 5.7 28.3 6.4
## 10 Austria 12.7 1.1 30.2 1.4 9 16.8 4.9 16.8 7
## # ℹ 16 more rows
## spc_tbl_ [26 × 10] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Country: chr [1:26] "Belgium" "Denmark" "France" "W. Germany" ...
## $ Agr : num [1:26] 3.3 9.2 10.8 6.7 23.2 15.9 7.7 6.3 2.7 12.7 ...
## $ Min : num [1:26] 0.9 0.1 0.8 1.3 1 0.6 3.1 0.1 1.4 1.1 ...
## $ Man : num [1:26] 27.6 21.8 27.5 35.8 20.7 27.6 30.8 22.5 30.2 30.2 ...
## $ PS : num [1:26] 0.9 0.6 0.9 0.9 1.3 0.5 0.8 1 1.4 1.4 ...
## $ Con : num [1:26] 8.2 8.3 8.9 7.3 7.5 10 9.2 9.9 6.9 9 ...
## $ SI : num [1:26] 19.1 14.6 16.8 14.4 16.8 18.1 18.5 18 16.9 16.8 ...
## $ Fin : num [1:26] 6.2 6.5 6 5 2.8 1.6 4.6 6.8 5.7 4.9 ...
## $ SPS : num [1:26] 26.6 32.2 22.6 22.3 20.8 20.1 19.2 28.5 28.3 16.8 ...
## $ TC : num [1:26] 7.2 7.1 5.7 6.1 6.1 5.7 6.2 6.8 6.4 7 ...
## - attr(*, "spec")=
## .. cols(
## .. Country = col_character(),
## .. Agr = col_double(),
## .. Min = col_double(),
## .. Man = col_double(),
## .. PS = col_double(),
## .. Con = col_double(),
## .. SI = col_double(),
## .. Fin = col_double(),
## .. SPS = col_double(),
## .. TC = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
Dataset Eurojobs.csv terdiri dari persentase populasi pekerja pada lapangan usaha (industri) yang berbeda di 26 negera di Eropa pada tahun 1979. Dataset ini memiliki 10 variabel.
- Country : nama negara
- Agr : % dari pekerja di Agriculture
- Min : % dari pekerja di Mining
- Man : % dari pekerja di Manufacturing
- PS : % dari pekerja di Power Supplies Industries
- Con : % dari pekerja di Construction
- SI : % dari pekerja di Service Industries
- Fin : % dari pekerja di Finance
- SPS : % dari pekerja di Social and Personal Services
- TC : % dari pekerja di Transportation and Communications
Data Exploration
## Country Agr Min Man
## Length:26 Min. : 2.70 Min. :0.100 Min. : 7.90
## Class :character 1st Qu.: 7.70 1st Qu.:0.525 1st Qu.:23.00
## Mode :character Median :14.45 Median :0.950 Median :27.55
## Mean :19.13 Mean :1.254 Mean :27.01
## 3rd Qu.:23.68 3rd Qu.:1.800 3rd Qu.:30.20
## Max. :66.80 Max. :3.100 Max. :41.20
## PS Con SI Fin
## Min. :0.1000 Min. : 2.800 Min. : 5.20 Min. : 0.500
## 1st Qu.:0.6000 1st Qu.: 7.525 1st Qu.: 9.25 1st Qu.: 1.225
## Median :0.8500 Median : 8.350 Median :14.40 Median : 4.650
## Mean :0.9077 Mean : 8.165 Mean :12.96 Mean : 4.000
## 3rd Qu.:1.1750 3rd Qu.: 8.975 3rd Qu.:16.88 3rd Qu.: 5.925
## Max. :1.9000 Max. :11.500 Max. :19.10 Max. :11.300
## SPS TC
## Min. : 5.30 Min. :3.200
## 1st Qu.:16.25 1st Qu.:5.700
## Median :19.65 Median :6.700
## Mean :20.02 Mean :6.546
## 3rd Qu.:24.12 3rd Qu.:7.075
## Max. :32.40 Max. :9.400
Pada sektor agriculuture:
- Min: 2.70% pekerja berada di sektor pertanian (terendah).
- Max: 66.80% pekerja berada di sektor pertanian (tertinggi).
- Mean: 19.13%, rata-rata pekerja di sektor pertanian di antara 26 negara.
- Median: 14.45%, nilai tengah menunjukkan bahwa setengah negara memiliki persentase pekerja di sektor pertanian di bawah 14.45%
- Q1 (Kuartil pertama): 7.70%, menunjukkan 25% negara memiliki persentase pekerja di sektor pertanian lebih rendah dari 7.70%
- Q3 (Kuartil ketiga): 23.68%, menunjukkan 75% negara memiliki persentase pekerja di sektor pertanian lebih rendah dari 23.68%.
Begitu juga dengan sektor lainnya
data_long <- data %>%
pivot_longer(cols = -Country, names_to = "Industri", values_to = "Persentase")
ggplot(data_long, aes(x = Industri, y = Persentase)) +
geom_boxplot(fill = "lightgreen") +
coord_flip() +
labs(title = "Sebaran Persentase Pekerja per Industri",
y = "Persentase (%)", x = "Industri") +
theme_minimal()Distribusi persentase pekerja di 26 negara Eropa tahun 1979 menunjukkan pola yang sangat beragam: manufaktur tetap penyerap tenaga kerja terbesar (median ≈ 25%) sementara sektor pertanian menampilkan rentang paling lebar (≈ 0–67%), menegaskan jurang modernisasi antar‑negara; ekonomi jasa (Service Industries serta Social & Personal Services) sudah tumbuh pesat tetapi belum merata, sedangkan sektor padat modal seperti energi dan keuangan konsisten kecil di hampir semua negara. Terlihat pula sejumlah pencilan (outlier) penting—misalnya negara dengan tenaga kerja agraris di atas 60%, manufaktur sekitar 40%, atau transportasi‑komunikasi jauh di atas rata‑rata—yang menandakan spesialisasi ekonomi unik atau tahap pembangunan berbeda‑beda di Benua Eropa.
## # A tibble: 26 × 10
## Country Agr Min Man PS Con SI Fin SPS TC
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Belgium 3.3 0.9 27.6 0.9 8.2 19.1 6.2 26.6 7.2
## 2 Denmark 9.2 0.1 21.8 0.6 8.3 14.6 6.5 32.2 7.1
## 3 France 10.8 0.8 27.5 0.9 8.9 16.8 6 22.6 5.7
## 4 W. Germany 6.7 1.3 35.8 0.9 7.3 14.4 5 22.3 6.1
## 5 Ireland 23.2 1 20.7 1.3 7.5 16.8 2.8 20.8 6.1
## 6 Italy 15.9 0.6 27.6 0.5 10 18.1 1.6 20.1 5.7
## 7 Luxembourg 7.7 3.1 30.8 0.8 9.2 18.5 4.6 19.2 6.2
## 8 Netherlands 6.3 0.1 22.5 1 9.9 18 6.8 28.5 6.8
## 9 United Kingdom 2.7 1.4 30.2 1.4 6.9 16.9 5.7 28.3 6.4
## 10 Austria 12.7 1.1 30.2 1.4 9 16.8 4.9 16.8 7
## # ℹ 16 more rows
dplyr::select(data, -Country) %>%
summarise_all(mean) %>%
pivot_longer(cols = everything(), names_to = "Industri", values_to = "RataRata") %>%
ggplot(aes(x = reorder(Industri, -RataRata), y = RataRata)) +
geom_col(fill = "steelblue") +
labs(title = "Rata-rata Persentase Pekerja per Industri (1979)",
x = "Industri", y = "Rata-rata (%)") +
theme_minimal()Rata‑rata tahun 1979 menunjukkan bahwa hampir seperempat tenaga kerja Eropa masih terserap di manufaktur (±26%), diikuti jasa sosial‑personal (±20%) dan pertanian (±19%), sehingga ekonomi benua ini berada di persimpangan antara basis industri klasik dan kebangkitan sektor jasa; service industries lain seperti perdagangan/perhotelan menyumbang ±14%, sementara konstruksi (±8%) dan transportasi‑komunikasi (±6%) menempati lapisan menengah, dan sektor padat modal—keuangan (±4%), pertambangan serta energi (keduanya ±1%)—mempekerjakan proporsi terkecil, menegaskan peran kapital‐intensifnya daripada labour‐intensif.
data_long <- data %>%
pivot_longer(cols = -Country, names_to = "Industri", values_to = "Persentase")
ggplot(data_long, aes(x = Industri, y = Persentase, fill = Industri)) +
geom_col(show.legend = FALSE) +
facet_wrap(~ Country, scales = "free_y") +
labs(title = "Sebaran Persentase Pekerja per Industri di Tiap Negara",
x = "Industri", y = "Persentase (%)") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))Panel‑plot ini menegaskan betapa heterogennya struktur tenaga kerja Eropa tahuun 1979: negara industri‑berat seperti Jerman Barat, Cekoslowakia, dan Swiss menunjukkan porsi manufaktur di atas 30%, sedangkan Yunani, Turki, Portugal, dan Rumania masih sangat agraris (Agr≥40%). Blok timur (Bulgaria, Polandia,USSR) dan ekonomi Skandinavia (Swedia, Finlandia) menonjolkan jasa sosial‑personal (SPS) dan layanan publik yang besar, sejalan dengan model welfare‑state, sementara pusat keuangan Britania Raya, Swiss, Belanda memperlihatkan sektor jasa lain (SI) dan keuangan (Fin) lebih tinggi. Negara kecil transit‑logistik seperti Belgia dan Luxembourg punya andil signifikan di transportasi‑komunikasi (TC). Secara keseluruhan, pola ini merefleksikan perbedaan tahap industrialisasi, kebijakan sosial, dan spesialisasi ekonomi lintas kawasan Eropa menjelang 1980.
cs_all <- cshp()
cs1979 <- cs_all %>%
filter(start <= as.Date("1979-12-31") & end >= as.Date("1979-01-01"))
europe_1979 <- c(
"United Kingdom", "Ireland", "Netherlands", "Belgium", "Luxembourg",
"France", "Switzerland", "Spain", "Portugal", "German Federal Republic",
"German Democratic Republic", "Poland", "Austria", "Hungary",
"Czechoslovakia", "Italy/Sardinia", "Malta", "Albania", "Yugoslavia",
"Greece", "Cyprus", "Bulgaria", "Rumania", "Russia (Soviet Union)",
"Finland", "Sweden", "Norway", "Denmark", "Iceland","Turkey (Ottoman Empire)"
)
cs_europe_1979 <- cs_all %>%
filter(start <= as.Date("1979-12-31") & end >= as.Date("1979-01-01")) %>%
filter(country_name %in% europe_1979)
unique(cs_europe_1979$country_name)## [1] "United Kingdom" "Ireland"
## [3] "Netherlands" "Belgium"
## [5] "Luxembourg" "France"
## [7] "Switzerland" "Spain"
## [9] "Portugal" "German Federal Republic"
## [11] "German Democratic Republic" "Poland"
## [13] "Austria" "Hungary"
## [15] "Czechoslovakia" "Italy/Sardinia"
## [17] "Malta" "Albania"
## [19] "Yugoslavia" "Greece"
## [21] "Cyprus" "Bulgaria"
## [23] "Rumania" "Russia (Soviet Union)"
## [25] "Finland" "Sweden"
## [27] "Norway" "Denmark"
## [29] "Iceland" "Turkey (Ottoman Empire)"
## [1] "Belgium" "Denmark" "France" "W. Germany"
## [5] "Ireland" "Italy" "Luxembourg" "Netherlands"
## [9] "United Kingdom" "Austria" "Finland" "Greece"
## [13] "Norway" "Portugal" "Spain" "Sweden"
## [17] "Switzerland" "Turkey" "Bulgaria" "Czechoslovakia"
## [21] "E. Germany" "Hungary" "Poland" "Rumania"
## [25] "USSR" "Yugoslavia"
ggplot(cs_europe_1979) +
geom_sf(aes(fill = country_name)) +
labs(
title = "Peta Negara-Negara Eropa Tahun 1979",
caption = "Sumber: cshapes"
) +
theme_minimal() +
theme(legend.position = "none")name_mapping <- c(
"W. Germany" = "German Federal Republic",
"E. Germany" = "German Democratic Republic",
"USSR" = "Russia (Soviet Union)",
"Czechoslovakia" = "Czechoslovakia",
"Yugoslavia" = "Yugoslavia",
"Rumania" = "Rumania",
"Turkey" = "Turkey (Ottoman Empire)",
"Italy" = "Italy/Sardinia",
"United Kingdom" = "United Kingdom",
"Belgium" = "Belgium",
"Denmark" = "Denmark",
"France" = "France",
"Ireland" = "Ireland",
"Luxembourg" = "Luxembourg",
"Netherlands" = "Netherlands",
"Austria" = "Austria",
"Finland" = "Finland",
"Greece" = "Greece",
"Norway" = "Norway",
"Portugal" = "Portugal",
"Spain" = "Spain",
"Sweden" = "Sweden",
"Switzerland" = "Switzerland",
"Hungary" = "Hungary",
"Poland" = "Poland",
"Bulgaria" = "Bulgaria"
)## # A tibble: 26 × 11
## Country Agr Min Man PS Con SI Fin SPS TC country_map
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 Belgium 3.3 0.9 27.6 0.9 8.2 19.1 6.2 26.6 7.2 Belgium
## 2 Denmark 9.2 0.1 21.8 0.6 8.3 14.6 6.5 32.2 7.1 Denmark
## 3 France 10.8 0.8 27.5 0.9 8.9 16.8 6 22.6 5.7 France
## 4 W. Germany 6.7 1.3 35.8 0.9 7.3 14.4 5 22.3 6.1 German Fed…
## 5 Ireland 23.2 1 20.7 1.3 7.5 16.8 2.8 20.8 6.1 Ireland
## 6 Italy 15.9 0.6 27.6 0.5 10 18.1 1.6 20.1 5.7 Italy/Sard…
## 7 Luxembourg 7.7 3.1 30.8 0.8 9.2 18.5 4.6 19.2 6.2 Luxembourg
## 8 Netherlands 6.3 0.1 22.5 1 9.9 18 6.8 28.5 6.8 Netherlands
## 9 United Kin… 2.7 1.4 30.2 1.4 6.9 16.9 5.7 28.3 6.4 United Kin…
## 10 Austria 12.7 1.1 30.2 1.4 9 16.8 4.9 16.8 7 Austria
## # ℹ 16 more rows
library(dplyr)
mapdata <- cs_europe_1979 %>%
left_join(data, by = c("country_name" = "country_map"))## [1] TRUE
## [1] FALSE
plot_variable_map <- function(mapdata, var, title = NULL) {
ggplot(mapdata) +
geom_sf(aes_string(fill = var), color = "black", size = 0.2) +
scale_fill_viridis_c(option = "plasma", direction = -1) +
labs(
title = title %||% paste("Sebaran Variabel", var),
fill = var
) +
theme_minimal() +
theme(
plot.title = element_text(size = 14, face = "bold"),
legend.title = element_text(size = 10),
legend.text = element_text(size = 8)
)
}
vars_to_plot <- c("Agr", "Min", "Man", "PS", "Con", "SI", "Fin", "SPS", "TC")
var_labels <- c(
Agr = "Persentase Pekerja Agrikultur",
Min = "Persentase Pekerja Pertambangan",
Man = "Persentase Pekerja Manufaktur",
PS = "Persentase Pekerja Jasa Publik",
Con = "Persentase Pekerja Konstruksi",
SI = "Persentase Pekerja Industri Sekunder",
Fin = "Persentase Pekerja Finansial",
SPS = "Persentase Pekerja Jasa Pribadi & Sosial",
TC = "Persentase Pekerja Transportasi & Komunikasi"
)
for (v in vars_to_plot) {
print(plot_variable_map(mapdata, v, paste("Sebaran", var_labels[[v]], "(1979)")))
}## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Pilih hanya variabel numerik yang mau dianalisis korelasinya
num_vars <- mapdata %>%
st_drop_geometry() %>% # buang kolom geometri
dplyr::select(Agr, Min, Man, PS, Con, SI, Fin, SPS, TC)
# Hitung matriks korelasi
cor_matrix <- cor(num_vars, use = "complete.obs")
# Tampilkan dengan corrplot
corrplot(cor_matrix, method = "color", type = "upper",
addCoef.col = "black", tl.col = "black", tl.srt = 45,
col = colorRampPalette(c("blue", "white", "red"))(200),
title = "Matriks Korelasi Seluruh Variabel",
mar = c(0,0,2,0))pairs.panels(cor_matrix,
method = "pearson", # correlation method
hist.col = "#00AFBB", #Coloring histogram
density = TRUE, # show density plots
ellipses = TRUE, # show correlation ellipses
smooth = TRUE, #show loess smooths
pch = 20, #Scatter = cirlce / dot
rug = TRUE, #Rug under histogram
stars = TRUE #Significance of corr
)Plot korelasi ini menunjukkan adanya hubungan yang cukup kuat antar berbagai sektor industri, dengan pola korelasi negatif yang menonjol antara sektor Agrikultur (Agr) dan sektor-sektor lain seperti Manufaktur (r = –0.72), Jasa Sosial-Pribadi (SPS; r = –0.88), serta Industri (SI; r = –0.87), yang semuanya signifikan. Ini mengindikasikan bahwa negara dengan proporsi pekerja tinggi di sektor agrikultur cenderung memiliki proporsi yang lebih rendah di sektor-sektor modern lainnya. Hal ini menunjukkan bahwa variabel Agr cenderung mengalami multikolinearitas terhadap variabel lain, khususnya terhadap sektor-sektor yang menunjukkan modernisasi ekonomi. Di sisi lain, korelasi positif yang kuat terlihat antara sektor-sektor modern seperti SI dan Fin (r = 0.85) serta SPS dan TC (r = 0.74), memperkuat indikasi keterkaitan struktural antara sektor jasa dalam perekonomian negara-negara tersebut, oleh karena itu dilanjutkan dengan pengecekan multikolinearitas menggunakan nilai VIF.
data_vif <- mapdata %>%
st_drop_geometry() %>%
dplyr::select(Agr, Min, Man, PS, Con, SI, Fin, SPS, TC)
vif_result <- vif(data_vif)
print(vif_result)## Variables VIF
## 1 Agr 14253.56341
## 2 Min 54.37608
## 3 Man 2937.18770
## 4 PS 10.36296
## 5 Con 151.53562
## 6 SI 1247.20513
## 7 Fin 463.56305
## 8 SPS 2702.03160
## 9 TC 116.79415
Terlihat bahwa variabel Agr memiliki nilai VIF yang paling tinggi oleh karena itu, peubah Agr direduksi
data_vif <- mapdata %>%
st_drop_geometry() %>%
dplyr::select(Min, Man, PS, Con, SI, Fin, SPS, TC)
vif_result <- vif(data_vif)
print(vif_result)## Variables VIF
## 1 Min 2.705855
## 2 Man 2.153257
## 3 PS 2.116425
## 4 Con 2.071399
## 5 SI 2.561013
## 6 Fin 1.721370
## 7 SPS 2.914605
## 8 TC 2.970558
Setelah peubah Agr direduksi, nilai VIF untuk keseluruhan peubah kecil atau dibawah 10 yang menandakan sudah tidak ada lagi indikasi multikolenieritas, oleh karena itu peubah Agr tidak diikutsertakan dalam analisis kedepannya
Hierarchical Clustering
## Simple feature collection with 26 features and 20 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -180 ymin: 27.6375 xmax: 180 ymax: 77.73221
## Geodetic CRS: WGS 84
## First 10 features:
## gwcode country_name start end status owner
## 1 200 United Kingdom 1921-12-06 2019-12-31 independent 200
## 2 205 Ireland 1921-12-06 2019-12-31 independent 205
## 3 210 Netherlands 1886-01-01 2019-12-31 independent 210
## 4 211 Belgium 1886-01-01 2019-12-31 independent 211
## 5 212 Luxembourg 1886-01-01 2019-12-31 independent 212
## 6 220 France 1919-06-28 2019-12-31 independent 220
## 7 225 Switzerland 1886-01-01 2019-12-31 independent 225
## 8 230 Spain 1886-01-01 2019-12-31 independent 230
## 9 235 Portugal 1886-01-01 2019-12-31 independent 235
## 10 260 German Federal Republic 1949-09-21 1990-10-02 independent 260
## capname caplong caplat b_def fid Country Min Man PS Con
## 1 London -0.116667 51.50000 1 74 United Kingdom 1.4 30.2 1.4 6.9
## 2 Dublin -6.248889 53.33306 1 75 Ireland 1.0 20.7 1.3 7.5
## 3 Amsterdam 4.916667 52.35000 1 76 Netherlands 0.1 22.5 1.0 9.9
## 4 Brussels 4.333333 50.83333 1 77 Belgium 0.9 27.6 0.9 8.2
## 5 Luxembourg 6.130000 49.61167 1 78 Luxembourg 3.1 30.8 0.8 9.2
## 6 Paris 2.333333 48.86666 1 80 France 0.8 27.5 0.9 8.9
## 7 Bern 7.466667 46.91667 1 81 Switzerland 0.2 37.8 0.8 9.5
## 8 Madrid -3.683333 40.40000 1 82 Spain 0.8 28.5 0.7 11.5
## 9 Lisbon -9.133333 38.71667 1 83 Portugal 0.3 24.5 0.6 8.4
## 10 Bonn 7.100000 50.73333 1 89 W. Germany 1.3 35.8 0.9 7.3
## SI Fin SPS TC geometry
## 1 16.9 5.7 28.3 6.4 MULTIPOLYGON (((-1.241664 5...
## 2 16.8 2.8 20.8 6.1 MULTIPOLYGON (((-7.252509 5...
## 3 18.0 6.8 28.5 6.8 MULTIPOLYGON (((7.207575 53...
## 4 19.1 6.2 26.6 7.2 MULTIPOLYGON (((6.011798 50...
## 5 18.5 4.6 19.2 6.2 MULTIPOLYGON (((6.125963 50...
## 6 16.8 6.0 22.6 5.7 MULTIPOLYGON (((9.50739 42....
## 7 17.5 5.3 15.4 5.7 MULTIPOLYGON (((9.572112 47...
## 8 9.7 8.5 11.8 5.5 MULTIPOLYGON (((-17.96389 2...
## 9 13.3 2.7 16.7 5.7 MULTIPOLYGON (((-16.96 32.8...
## 10 14.4 5.0 22.3 6.1 MULTIPOLYGON (((8.692773 54...
## [1] 26
Dotplot
par(mfrow = c(2, 4))
stripchart(mapdata$Min, "stack", pch=19, cex=1)
mtext("Min", side=3, line=0.5)
stripchart(mapdata$Man, "stack", pch=19, cex=1)
mtext("Man", side=3, line=0.5)
stripchart(mapdata$PS, "stack", pch=19, cex=1)
mtext("PS", side=3, line=0.5)
stripchart(mapdata$Con, "stack", pch=19, cex=1)
mtext("Con", side=3, line=0.5)
stripchart(mapdata$SI, "stack", pch=19, cex=1)
mtext("SI", side=3, line=0.5)
stripchart(mapdata$Fin, "stack", pch=19, cex=1)
mtext("Fin", side=3, line=0.5)
stripchart(mapdata$SPS, "stack", pch=19, cex=1)
mtext("SPS", side=3, line=0.5)
stripchart(mapdata$TC, "stack", pch=19, cex=1)
mtext("TC", side=3, line=0.5)Berdasarkan dotplot, sulit menemukan jumlah cluster dikarenakan tidak terlihat adanya indikasi gerombol dari setiap peubah
plot(mapdata$Min,mapdata$SI,pch=19,cex=1,ylab="SI",xlab="Min",col=2)
text(mapdata$Min,mapdata$SI,mapdata$country_name,cex=0.7)Berdasarkan plot diatas, jika menggunakan 2 peubah yaitu SI dan Min dapat terlihat adanya indikasi cluster, terlihat bahwa amatan yaitu negara di eropa terbagi menjadi 2 bagian antara kanan atas dengan kiri bawah
Natural Breaks (jenks) Method
partisi1 <- classIntervals(mapdata$Min)
partisi2 <- classIntervals(mapdata$Min,n=4,style="jenks")
mapdata$cl1<-findCols(partisi1)
mapdata$cl2<-findCols(partisi2)
mapdata## Simple feature collection with 26 features and 22 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -180 ymin: 27.6375 xmax: 180 ymax: 77.73221
## Geodetic CRS: WGS 84
## First 10 features:
## gwcode country_name start end status owner
## 1 200 United Kingdom 1921-12-06 2019-12-31 independent 200
## 2 205 Ireland 1921-12-06 2019-12-31 independent 205
## 3 210 Netherlands 1886-01-01 2019-12-31 independent 210
## 4 211 Belgium 1886-01-01 2019-12-31 independent 211
## 5 212 Luxembourg 1886-01-01 2019-12-31 independent 212
## 6 220 France 1919-06-28 2019-12-31 independent 220
## 7 225 Switzerland 1886-01-01 2019-12-31 independent 225
## 8 230 Spain 1886-01-01 2019-12-31 independent 230
## 9 235 Portugal 1886-01-01 2019-12-31 independent 235
## 10 260 German Federal Republic 1949-09-21 1990-10-02 independent 260
## capname caplong caplat b_def fid Country Min Man PS Con
## 1 London -0.116667 51.50000 1 74 United Kingdom 1.4 30.2 1.4 6.9
## 2 Dublin -6.248889 53.33306 1 75 Ireland 1.0 20.7 1.3 7.5
## 3 Amsterdam 4.916667 52.35000 1 76 Netherlands 0.1 22.5 1.0 9.9
## 4 Brussels 4.333333 50.83333 1 77 Belgium 0.9 27.6 0.9 8.2
## 5 Luxembourg 6.130000 49.61167 1 78 Luxembourg 3.1 30.8 0.8 9.2
## 6 Paris 2.333333 48.86666 1 80 France 0.8 27.5 0.9 8.9
## 7 Bern 7.466667 46.91667 1 81 Switzerland 0.2 37.8 0.8 9.5
## 8 Madrid -3.683333 40.40000 1 82 Spain 0.8 28.5 0.7 11.5
## 9 Lisbon -9.133333 38.71667 1 83 Portugal 0.3 24.5 0.6 8.4
## 10 Bonn 7.100000 50.73333 1 89 W. Germany 1.3 35.8 0.9 7.3
## SI Fin SPS TC geometry cl1 cl2
## 1 16.9 5.7 28.3 6.4 MULTIPOLYGON (((-1.241664 5... 5 3
## 2 16.8 2.8 20.8 6.1 MULTIPOLYGON (((-7.252509 5... 4 2
## 3 18.0 6.8 28.5 6.8 MULTIPOLYGON (((7.207575 53... 1 1
## 4 19.1 6.2 26.6 7.2 MULTIPOLYGON (((6.011798 50... 3 2
## 5 18.5 4.6 19.2 6.2 MULTIPOLYGON (((6.125963 50... 6 4
## 6 16.8 6.0 22.6 5.7 MULTIPOLYGON (((9.50739 42.... 3 2
## 7 17.5 5.3 15.4 5.7 MULTIPOLYGON (((9.572112 47... 1 1
## 8 9.7 8.5 11.8 5.5 MULTIPOLYGON (((-17.96389 2... 3 2
## 9 13.3 2.7 16.7 5.7 MULTIPOLYGON (((-16.96 32.8... 1 1
## 10 14.4 5.0 22.3 6.1 MULTIPOLYGON (((8.692773 54... 4 3
Kolom cl1** dan cl2 adalah jumlah cluster yang membagi persentase pekerja ke dalam rentang nilai berbeda: cl1 memakai pembagian “natural breaks” bawaan yang secara otomatis menghasilkan enam gerombol, sedangkan cl2 menggunakan metode Jenks dengan jumlah cluster ditentukan yaitu empat
Linkage Method
Euclidean Distance Matrix (non-standarized)
datacl <- mapdata %>%
st_drop_geometry() %>%
dplyr::select(Min, Man, PS, Con, SI, Fin, SPS, TC)
datacl## Min Man PS Con SI Fin SPS TC
## 1 1.4 30.2 1.4 6.9 16.9 5.7 28.3 6.4
## 2 1.0 20.7 1.3 7.5 16.8 2.8 20.8 6.1
## 3 0.1 22.5 1.0 9.9 18.0 6.8 28.5 6.8
## 4 0.9 27.6 0.9 8.2 19.1 6.2 26.6 7.2
## 5 3.1 30.8 0.8 9.2 18.5 4.6 19.2 6.2
## 6 0.8 27.5 0.9 8.9 16.8 6.0 22.6 5.7
## 7 0.2 37.8 0.8 9.5 17.5 5.3 15.4 5.7
## 8 0.8 28.5 0.7 11.5 9.7 8.5 11.8 5.5
## 9 0.3 24.5 0.6 8.4 13.3 2.7 16.7 5.7
## 10 1.3 35.8 0.9 7.3 14.4 5.0 22.3 6.1
## 11 2.9 41.2 1.3 7.6 11.2 1.2 22.1 8.4
## 12 2.5 25.7 0.9 8.4 7.5 0.9 16.1 6.9
## 13 1.1 30.2 1.4 9.0 16.8 4.9 16.8 7.0
## 14 3.1 29.6 1.9 8.2 9.4 0.9 17.2 8.0
## 15 2.9 35.5 1.2 8.7 9.2 0.9 17.9 7.0
## 16 0.6 27.6 0.5 10.0 18.1 1.6 20.1 5.7
## 19 1.5 16.8 1.1 4.9 6.4 11.3 5.3 4.0
## 20 0.6 17.6 0.6 8.1 11.5 2.4 11.0 6.7
## 22 1.9 32.3 0.6 7.9 8.0 0.7 18.2 6.7
## 23 2.1 30.1 0.6 8.7 5.9 1.3 11.7 5.0
## 24 1.4 25.8 0.6 9.2 6.1 0.5 23.6 9.3
## 25 0.4 25.9 1.3 7.4 14.7 5.5 24.3 7.6
## 26 0.4 25.9 0.8 7.2 14.4 6.0 32.4 6.8
## 27 0.5 22.4 0.8 8.6 16.9 4.7 27.6 9.4
## 28 0.1 21.8 0.6 8.3 14.6 6.5 32.2 7.1
## 30 0.7 7.9 0.1 2.8 5.2 1.1 11.9 3.2
## United Kingdom Ireland Netherlands Belgium
## United Kingdom 0.000000 12.471568 8.529947 4.191658
## Ireland 12.471568 0.000000 9.333810 9.998500
## Netherlands 8.529947 9.333810 0.000000 5.906776
## Belgium 4.191658 9.998500 5.906776 0.000000
## Luxembourg 9.773433 10.874741 13.052203 8.646965
## France 6.706713 7.876547 8.037413 4.908156
## Switzerland 15.288558 18.258149 20.239071 15.404220
## Spain 18.911372 15.540270 19.786359 18.092264
## Portugal 13.914022 6.742403 13.630847 12.500000
## German Federal Republic 8.637708 15.529005 15.499355 10.556515
## German Democratic Republic 14.796283 21.558525 22.000682 17.279468
## Poland 16.865646 11.876447 17.807021 16.709279
## Austria 11.737121 10.664896 14.256227 10.523783
## Hungary 14.500000 12.625767 17.349640 14.866741
## Czechoslovakia 14.982323 17.166537 20.074113 16.388411
## Italy/Sardinia 10.188229 7.644606 11.195535 8.375560
## Yugoslavia 29.326268 21.150177 27.574445 27.913438
## Greece 22.381019 11.630563 19.887936 20.396078
## Bulgaria 14.581152 14.999667 18.621224 15.733404
## Rumania 20.548966 17.221498 22.923787 20.811776
## Russia (Soviet Union) 14.123385 12.938702 14.992998 14.814857
## Finland 6.486139 7.321885 6.989278 5.407402
## Sweden 6.576473 13.371238 6.913031 7.751129
## Norway 8.682742 8.083935 3.884585 6.348228
## Denmark 9.822423 12.354756 5.351635 9.278470
## Turkey (Ottoman Empire) 30.879281 20.310835 27.378641 29.482876
## Luxembourg France Switzerland Spain Portugal
## United Kingdom 9.773433 6.706713 15.288558 18.911372 13.914022
## Ireland 10.874741 7.876547 18.258149 15.540270 6.742403
## Netherlands 13.052203 8.037413 20.239071 19.786359 13.630847
## Belgium 8.646965 4.908156 15.404220 18.092264 12.500000
## Luxembourg 0.000000 5.739338 8.583705 12.797656 9.239048
## France 5.739338 0.000000 12.634872 13.458826 8.218272
## Switzerland 8.583705 12.634872 0.000000 13.226489 14.291256
## Spain 12.797656 13.458826 13.226489 0.000000 9.824459
## Portugal 9.239048 8.218272 14.291256 9.824459 0.000000
## German Federal Republic 7.645260 8.871866 8.217664 14.702721 12.961867
## German Democratic Republic 13.751727 15.996562 11.462548 18.743265 18.162874
## Poland 13.107631 12.750294 16.559287 10.170054 6.711930
## Austria 3.760319 6.646804 7.967434 10.016986 7.274613
## Hungary 10.362915 11.243220 13.116783 10.587256 7.718160
## Czechoslovakia 11.182576 13.269891 10.467569 12.608331 12.304064
## Italy/Sardinia 5.238320 5.359104 11.860860 13.792752 6.933974
## Yugoslavia 24.627018 23.863152 26.982402 15.631059 18.101105
## Greece 17.408906 16.594879 21.793806 13.151046 9.198369
## Bulgaria 11.494781 12.297561 12.489596 11.608187 9.949372
## Rumania 15.136710 16.394511 15.110261 8.867920 10.812030
## Russia (Soviet Union) 15.082109 12.733028 19.462014 15.607370 10.990450
## Finland 8.832327 4.036087 15.395129 14.790199 8.638866
## Sweden 15.121839 10.422572 21.148286 21.904566 16.224981
## Norway 12.690548 8.160270 20.032723 19.412625 12.409271
## Denmark 16.717655 11.516944 23.484889 22.413389 16.299693
## Turkey (Ottoman Empire) 28.688848 26.482636 33.571863 24.098340 20.119394
## German Federal Republic German Democratic Republic
## United Kingdom 8.637708 14.796283
## Ireland 15.529005 21.558525
## Netherlands 15.499355 22.000682
## Belgium 10.556515 17.279468
## Luxembourg 7.645260 13.751727
## France 8.871866 15.996562
## Switzerland 8.217664 11.462548
## Spain 14.702721 18.743265
## Portugal 12.961867 18.162874
## German Federal Republic 0.000000 7.872738
## German Democratic Republic 7.872738 0.000000
## Poland 14.427751 17.124252
## Austria 8.448077 14.188376
## Hungary 10.720075 12.760094
## Czechoslovakia 8.289753 7.576279
## Italy/Sardinia 10.267911 15.990935
## Yugoslavia 27.639465 32.113860
## Greece 21.810089 26.279650
## Bulgaria 9.469952 10.458489
## Rumania 15.319595 16.533905
## Russia (Soviet Union) 14.310136 16.493029
## Finland 10.275213 16.631296
## Sweden 14.224627 19.562208
## Norway 15.073818 20.891146
## Denmark 17.315600 22.989780
## Turkey (Ottoman Empire) 31.876010 36.128936
## Poland Austria Hungary Czechoslovakia
## United Kingdom 16.865646 11.737121 14.500000 14.982323
## Ireland 11.876447 10.664896 12.625767 17.166537
## Netherlands 17.807021 14.256227 17.349640 20.074113
## Belgium 16.709279 10.523783 14.866741 16.388411
## Luxembourg 13.107631 3.760319 10.362915 11.182576
## France 12.750294 6.646804 11.243220 13.269891
## Switzerland 16.559287 7.967434 13.116783 10.467569
## Spain 10.170054 10.016986 10.587256 12.608331
## Portugal 6.711930 7.274613 7.718160 12.304064
## German Federal Republic 14.427751 8.448077 10.720075 8.289753
## German Democratic Republic 17.124252 14.188376 12.760094 7.576279
## Poland 0.000000 11.216506 4.758151 10.125216
## Austria 11.216506 0.000000 8.784646 10.316492
## Hungary 4.758151 8.784646 0.000000 6.092618
## Czechoslovakia 10.125216 10.316492 6.092618 0.000000
## Italy/Sardinia 11.841875 5.829237 10.263040 12.494399
## Yugoslavia 18.080929 22.067850 21.276748 25.492352
## Greece 10.663020 15.117209 14.097518 19.536120
## Bulgaria 7.000000 10.199510 3.898718 3.728270
## Rumania 6.737210 12.787494 7.406079 9.146037
## Russia (Soviet Union) 8.128961 14.335620 8.586035 12.020815
## Finland 12.097107 9.106591 11.036304 13.886684
## Sweden 18.580097 16.521199 17.512281 19.082977
## Norway 16.007498 13.570925 15.517087 18.738196
## Denmark 19.028663 17.811794 18.861336 21.472541
## Turkey (Ottoman Empire) 19.716491 26.926381 24.038719 29.480502
## Italy/Sardinia Yugoslavia Greece Bulgaria
## United Kingdom 10.188229 29.32627 22.381019 14.581152
## Ireland 7.644606 21.15018 11.630563 14.999667
## Netherlands 11.195535 27.57444 19.887936 18.621224
## Belgium 8.375560 27.91344 20.396078 15.733404
## Luxembourg 5.238320 24.62702 17.408906 11.494781
## France 5.359104 23.86315 16.594879 12.297561
## Switzerland 11.860860 26.98240 21.793806 12.489596
## Spain 13.792752 15.63106 13.151046 11.608187
## Portugal 6.933974 18.10110 9.198369 9.949372
## German Federal Republic 10.267911 27.63946 21.810089 9.469952
## German Democratic Republic 15.990935 32.11386 26.279650 10.458489
## Poland 11.841875 18.08093 10.663020 7.000000
## Austria 5.829237 22.06785 15.117209 10.199510
## Hungary 10.263040 21.27675 14.097518 3.898718
## Czechoslovakia 12.494399 25.49235 19.536120 3.728270
## Italy/Sardinia 0.000000 24.42806 15.219396 11.646029
## Yugoslavia 24.428058 0.00000 12.527570 23.200862
## Greece 15.219396 12.52757 0.000000 16.876018
## Bulgaria 11.646029 23.20086 16.876018 0.000000
## Rumania 15.171684 18.27977 13.957435 7.445133
## Russia (Soviet Union) 13.226867 24.07198 16.351758 9.152049
## Finland 7.638717 23.80756 16.354204 12.243366
## Sweden 14.014635 30.39309 23.433310 17.732456
## Norway 10.492378 26.95181 18.456435 17.069271
## Denmark 14.880188 29.36443 22.224986 19.672570
## Turkey (Ottoman Empire) 26.081603 15.32775 13.299624 26.134269
## Rumania Russia (Soviet Union) Finland Sweden
## United Kingdom 20.548966 14.123385 6.486139 6.576473
## Ireland 17.221498 12.938702 7.321885 13.371238
## Netherlands 22.923787 14.992998 6.989278 6.913031
## Belgium 20.811776 14.814857 5.407402 7.751129
## Luxembourg 15.136710 15.082109 8.832327 15.121839
## France 16.394511 12.733028 4.036087 10.422572
## Switzerland 15.110261 19.462014 15.395129 21.148286
## Spain 8.867920 15.607370 14.790199 21.904566
## Portugal 10.812030 10.990450 8.638866 16.224981
## German Federal Republic 15.319595 14.310136 10.275213 14.224627
## German Democratic Republic 16.533905 16.493029 16.631296 19.562208
## Poland 6.737210 8.128961 12.097107 18.580097
## Austria 12.787494 14.335620 9.106591 16.521199
## Hungary 7.406079 8.586035 11.036304 17.512281
## Czechoslovakia 9.146037 12.020815 13.886684 19.082977
## Italy/Sardinia 15.171684 13.226867 7.638717 14.014635
## Yugoslavia 18.279770 24.071975 23.807562 30.393091
## Greece 13.957435 16.351758 16.354204 23.433310
## Bulgaria 7.445133 9.152049 12.243366 17.732456
## Rumania 0.000000 13.416781 16.831815 23.428402
## Russia (Soviet Union) 13.416781 0.000000 10.347947 13.706933
## Finland 16.831815 10.347947 0.000000 8.178019
## Sweden 23.428402 13.706933 8.178019 0.000000
## Norway 21.601620 12.769495 5.793099 7.208329
## Denmark 24.503877 14.337015 9.048204 4.309292
## Turkey (Ottoman Empire) 23.101299 23.181458 25.088244 29.762392
## Norway Denmark Turkey (Ottoman Empire)
## United Kingdom 8.682742 9.822423 30.87928
## Ireland 8.083935 12.354756 20.31083
## Netherlands 3.884585 5.351635 27.37864
## Belgium 6.348228 9.278470 29.48288
## Luxembourg 12.690548 16.717655 28.68885
## France 8.160270 11.516944 26.48264
## Switzerland 20.032723 23.484889 33.57186
## Spain 19.412625 22.413389 24.09834
## Portugal 12.409271 16.299693 20.11939
## German Federal Republic 15.073818 17.315600 31.87601
## German Democratic Republic 20.891146 22.989780 36.12894
## Poland 16.007498 19.028663 19.71649
## Austria 13.570925 17.811794 26.92638
## Hungary 15.517087 18.861336 24.03872
## Czechoslovakia 18.738196 21.472541 29.48050
## Italy/Sardinia 10.492378 14.880188 26.08160
## Yugoslavia 26.951809 29.364434 15.32775
## Greece 18.456435 22.224986 13.29962
## Bulgaria 17.069271 19.672570 26.13427
## Rumania 21.601620 24.503877 23.10130
## Russia (Soviet Union) 12.769495 14.337015 23.18146
## Finland 5.793099 9.048204 25.08824
## Sweden 7.208329 4.309292 29.76239
## Norway 0.000000 5.969087 26.06147
## Denmark 5.969087 0.000000 27.72887
## Turkey (Ottoman Empire) 26.061466 27.728866 0.00000
Cophenetic Corellation
## [1] 0.7604551
## [1] 0.7865332
#Complete
d1=dist(datacl)
hc= hclust(d1, "complete")
d2= cophenetic(hc)
cor.comp = cor (d1,d2)
cor.comp## [1] 0.7597071
#Ward
d1 <- dist(datacl)
hc <- hclust(d1, "ward.D")
d2 <- cophenetic(hc)
corward=cor(d1, d2)
corward## [1] 0.4884801
#Centroid
d1 <- dist(datacl)
hc <- hclust(d1, "centroid")
d2 <- cophenetic(hc)
corcent=cor(d1, d2)
corcent## [1] 0.7597557
Berdasarkan Cophenetic Corellation, jika menggunakan matriks jarak euclidean tanpa di standarisasi didapatkan bahwa nilai tertinggi diperoleh jika menggunakan average linkage, yaitu sebesar 0.7865332
Euclidean Distance Matrix (standarized)
## United Kingdom Ireland Netherlands Belgium
## United Kingdom 0.000000 2.128854 2.784278 1.857198
## Ireland 2.128854 0.000000 2.704444 2.314730
## Netherlands 2.784278 2.704444 0.000000 1.615921
## Belgium 1.857198 2.314730 1.615921 0.000000
## Luxembourg 3.106050 3.194806 3.754659 2.797269
## France 2.176238 2.071338 1.729461 1.398099
## Switzerland 3.406561 3.376774 3.117831 2.722247
## Spain 4.630820 4.264841 3.653089 3.925897
## Portugal 3.492823 2.367563 2.980749 2.766680
## German Federal Republic 1.911463 2.611834 3.131611 2.024304
## German Democratic Republic 3.481326 4.121792 5.141248 4.075999
## Poland 3.842104 3.118327 4.496571 3.900430
## Austria 2.197096 2.017716 2.679966 2.174809
## Hungary 3.878780 3.773670 5.367946 4.751438
## Czechoslovakia 3.564331 3.565864 4.809966 4.017661
## Italy/Sardinia 3.739920 2.885474 2.852434 2.687861
## Yugoslavia 5.417066 5.012223 6.052692 5.751929
## Greece 4.266752 2.750969 3.758823 3.565205
## Bulgaria 3.799724 3.422288 4.448289 3.681015
## Rumania 4.625750 3.929457 5.064422 4.584458
## Russia (Soviet Union) 4.548803 4.102031 4.344614 4.000701
## Finland 1.710339 1.870234 2.172200 1.695412
## Sweden 2.183799 2.728719 2.081390 1.621321
## Norway 3.239779 3.100368 2.281092 1.971916
## Denmark 3.064551 3.139385 1.728998 1.913380
## Turkey (Ottoman Empire) 7.005417 5.882189 7.322203 6.975945
## Luxembourg France Switzerland Spain Portugal
## United Kingdom 3.106050 2.176238 3.406561 4.630820 3.492823
## Ireland 3.194806 2.071338 3.376774 4.264841 2.367563
## Netherlands 3.754659 1.729461 3.117831 3.653089 2.980749
## Belgium 2.797269 1.398099 2.722247 3.925897 2.766680
## Luxembourg 0.000000 2.590611 3.243016 3.848529 3.416434
## France 2.590611 0.000000 1.985831 2.919303 1.972610
## Switzerland 3.243016 1.985831 0.000000 2.862956 2.465606
## Spain 3.848529 2.919303 2.862956 0.000000 3.104232
## Portugal 3.416434 1.972610 2.465606 3.104232 0.000000
## German Federal Republic 2.527962 1.760833 2.190709 3.647972 2.495986
## German Democratic Republic 3.413218 4.296125 4.454183 5.442631 4.631191
## Poland 3.032606 3.508984 4.136405 4.004394 2.928918
## Austria 2.723963 1.939532 2.373048 3.417022 2.840624
## Hungary 4.049772 4.715206 5.279530 5.570656 4.969085
## Czechoslovakia 2.819866 3.748105 3.997172 4.432895 3.787175
## Italy/Sardinia 3.003237 2.071850 2.290328 3.476381 1.676145
## Yugoslavia 5.788866 5.068101 5.775981 4.909996 4.997056
## Greece 3.930071 3.049447 3.633781 3.526701 1.574046
## Bulgaria 3.135473 3.310189 3.549299 3.990036 2.542873
## Rumania 3.516261 3.723544 3.816895 3.494919 2.787273
## Russia (Soviet Union) 4.326760 4.139482 4.695428 4.662901 3.515949
## Finland 3.682594 2.086228 3.203635 4.125931 2.841405
## Sweden 3.832322 2.078270 3.495983 4.361890 2.866156
## Norway 3.959648 2.924175 3.943175 4.641898 3.342825
## Denmark 4.125789 2.280847 3.699448 4.145629 2.876070
## Turkey (Ottoman Empire) 7.154294 6.423003 7.174045 7.056781 5.129281
## German Federal Republic German Democratic Republic
## United Kingdom 1.911463 3.481326
## Ireland 2.611834 4.121792
## Netherlands 3.131611 5.141248
## Belgium 2.024304 4.075999
## Luxembourg 2.527962 3.413218
## France 1.760833 4.296125
## Switzerland 2.190709 4.454183
## Spain 3.647972 5.442631
## Portugal 2.495986 4.631191
## German Federal Republic 0.000000 3.087630
## German Democratic Republic 3.087630 0.000000
## Poland 3.101222 3.004719
## Austria 2.204076 3.398859
## Hungary 4.164232 2.494510
## Czechoslovakia 2.888136 1.664958
## Italy/Sardinia 2.832038 4.709833
## Yugoslavia 5.135482 6.876221
## Greece 3.510200 4.983846
## Bulgaria 2.500259 2.917277
## Rumania 3.305269 4.090286
## Russia (Soviet Union) 3.899066 3.660471
## Finland 2.296645 3.845834
## Sweden 2.344783 4.499453
## Norway 3.401170 4.441425
## Denmark 3.071147 5.178487
## Turkey (Ottoman Empire) 6.392958 8.020179
## Poland Austria Hungary Czechoslovakia
## United Kingdom 3.842104 2.197096 3.878780 3.564331
## Ireland 3.118327 2.017716 3.773670 3.565864
## Netherlands 4.496571 2.679966 5.367946 4.809966
## Belgium 3.900430 2.174809 4.751438 4.017661
## Luxembourg 3.032606 2.723963 4.049772 2.819866
## France 3.508984 1.939532 4.715206 3.748105
## Switzerland 4.136405 2.373048 5.279530 3.997172
## Spain 4.004394 3.417022 5.570656 4.432895
## Portugal 2.928918 2.840624 4.969085 3.787175
## German Federal Republic 3.101222 2.204076 4.164232 2.888136
## German Democratic Republic 3.004719 3.398859 2.494510 1.664958
## Poland 0.000000 3.251652 2.931830 1.734211
## Austria 3.251652 0.000000 3.380534 3.024492
## Hungary 2.931830 3.380534 0.000000 2.198753
## Czechoslovakia 1.734211 3.024492 2.198753 0.000000
## Italy/Sardinia 3.535860 3.010821 5.325247 3.975108
## Yugoslavia 5.302411 5.340476 6.329391 6.063399
## Greece 2.733098 3.349992 4.869442 4.053181
## Bulgaria 1.459455 3.430151 3.826906 2.042874
## Rumania 1.911946 3.944939 4.359212 2.692212
## Russia (Soviet Union) 2.540305 4.083766 4.238674 3.294087
## Finland 3.611736 1.887206 3.999684 3.795910
## Sweden 4.070353 3.210012 5.209386 4.427430
## Norway 4.083596 3.115320 4.969826 4.517483
## Denmark 4.363259 3.584441 5.767370 4.951754
## Turkey (Ottoman Empire) 5.805518 7.257127 7.919549 7.145495
## Italy/Sardinia Yugoslavia Greece Bulgaria Rumania
## United Kingdom 3.739920 5.417066 4.266752 3.799724 4.625750
## Ireland 2.885474 5.012223 2.750969 3.422288 3.929457
## Netherlands 2.852434 6.052692 3.758823 4.448289 5.064422
## Belgium 2.687861 5.751929 3.565205 3.681015 4.584458
## Luxembourg 3.003237 5.788866 3.930071 3.135473 3.516261
## France 2.071850 5.068101 3.049447 3.310189 3.723544
## Switzerland 2.290328 5.775981 3.633781 3.549299 3.816895
## Spain 3.476381 4.909996 3.526701 3.990036 3.494919
## Portugal 1.676145 4.997056 1.574046 2.542873 2.787273
## German Federal Republic 2.832038 5.135482 3.510200 2.500259 3.305269
## German Democratic Republic 4.709833 6.876221 4.983846 2.917277 4.090286
## Poland 3.535860 5.302411 2.733098 1.459455 1.911946
## Austria 3.010821 5.340476 3.349992 3.430151 3.944939
## Hungary 5.325247 6.329391 4.869442 3.826906 4.359212
## Czechoslovakia 3.975108 6.063399 4.053181 2.042874 2.692212
## Italy/Sardinia 0.000000 6.329129 2.809650 3.084621 3.478610
## Yugoslavia 6.329129 0.000000 4.709772 5.645526 5.018509
## Greece 2.809650 4.709772 0.000000 2.876548 2.976682
## Bulgaria 3.084621 5.645526 2.876548 0.000000 1.741331
## Rumania 3.478610 5.018509 2.976682 1.741331 0.000000
## Russia (Soviet Union) 3.878408 6.837729 3.353008 2.458499 3.695740
## Finland 3.441709 5.249552 3.317867 3.614566 4.511161
## Sweden 3.257727 5.655063 3.727973 3.679657 4.654024
## Norway 3.389147 6.626604 3.548572 4.002133 5.184721
## Denmark 3.142171 5.936472 3.598793 4.047691 4.903991
## Turkey (Ottoman Empire) 6.390488 5.052574 4.745617 5.709432 5.333140
## Russia (Soviet Union) Finland Sweden Norway
## United Kingdom 4.548803 1.710339 2.183799 3.239779
## Ireland 4.102031 1.870234 2.728719 3.100368
## Netherlands 4.344614 2.172200 2.081390 2.281092
## Belgium 4.000701 1.695412 1.621321 1.971916
## Luxembourg 4.326760 3.682594 3.832322 3.959648
## France 4.139482 2.086228 2.078270 2.924175
## Switzerland 4.695428 3.203635 3.495983 3.943175
## Spain 4.662901 4.125931 4.361890 4.641898
## Portugal 3.515949 2.841405 2.866156 3.342825
## German Federal Republic 3.899066 2.296645 2.344783 3.401170
## German Democratic Republic 3.660471 3.845834 4.499453 4.441425
## Poland 2.540305 3.611736 4.070353 4.083596
## Austria 4.083766 1.887206 3.210012 3.115320
## Hungary 4.238674 3.999684 5.209386 4.969826
## Czechoslovakia 3.294087 3.795910 4.427430 4.517483
## Italy/Sardinia 3.878408 3.441709 3.257727 3.389147
## Yugoslavia 6.837729 5.249552 5.655063 6.626604
## Greece 3.353008 3.317867 3.727973 3.548572
## Bulgaria 2.458499 3.614566 3.679657 4.002133
## Rumania 3.695740 4.511161 4.654024 5.184721
## Russia (Soviet Union) 0.000000 3.732499 3.852573 3.109906
## Finland 3.732499 0.000000 1.885289 2.185745
## Sweden 3.852573 1.885289 0.000000 2.341445
## Norway 3.109906 2.185745 2.341445 0.000000
## Denmark 3.811592 2.406994 1.117308 2.084009
## Turkey (Ottoman Empire) 6.795206 6.689246 6.332430 7.316513
## Denmark Turkey (Ottoman Empire)
## United Kingdom 3.064551 7.005417
## Ireland 3.139385 5.882189
## Netherlands 1.728998 7.322203
## Belgium 1.913380 6.975945
## Luxembourg 4.125789 7.154294
## France 2.280847 6.423003
## Switzerland 3.699448 7.174045
## Spain 4.145629 7.056781
## Portugal 2.876070 5.129281
## German Federal Republic 3.071147 6.392958
## German Democratic Republic 5.178487 8.020179
## Poland 4.363259 5.805518
## Austria 3.584441 7.257127
## Hungary 5.767370 7.919549
## Czechoslovakia 4.951754 7.145495
## Italy/Sardinia 3.142171 6.390488
## Yugoslavia 5.936472 5.052574
## Greece 3.598793 4.745617
## Bulgaria 4.047691 5.709432
## Rumania 4.903991 5.333140
## Russia (Soviet Union) 3.811592 6.795206
## Finland 2.406994 6.689246
## Sweden 1.117308 6.332430
## Norway 2.084009 7.316513
## Denmark 0.000000 6.470535
## Turkey (Ottoman Empire) 6.470535 0.000000
Cophenetic Corellation
## [1] 0.8418725
## [1] 0.8770561
## [1] 0.8482454
## [1] 0.652164
## [1] 0.8180737
Berdasarkan Cophenetic Corellation, jika menggunakan matriks jarak euclidean yang di standarisasi didapatkan bahwa nilai tertinggi juga diperoleh jika menggunakan average linkage, yaitu sebesar 0.8770561. oleh karena itu jika menggunakan matriks jarak euclidean baiknya distandarisasi terlebih dahulu datanya.
Manhattan Distance Matrix (non-standarized)
## United Kingdom Ireland Netherlands Belgium
## United Kingdom 0.0 21.4 15.2 10.1
## Ireland 21.4 0.0 19.0 20.7
## Netherlands 15.2 19.0 0.0 11.7
## Belgium 10.1 20.7 11.7 0.0
## Luxembourg 17.2 19.6 24.8 17.1
## France 12.6 14.2 15.8 8.9
## Switzerland 26.6 29.4 32.2 27.5
## Spain 35.0 35.0 36.6 32.7
## Portugal 28.0 14.2 25.8 24.9
## German Federal Republic 16.1 22.1 29.5 20.8
## German Democratic Republic 31.7 33.3 44.5 35.2
## Poland 34.5 24.5 36.1 31.4
## Austria 15.4 18.2 25.0 17.7
## Hungary 29.1 27.1 39.7 30.4
## Czechoslovakia 32.3 31.3 42.7 34.8
## Italy/Sardinia 21.6 14.2 21.0 16.1
## Yugoslavia 57.3 43.7 54.3 57.2
## Greece 41.7 20.9 36.1 38.2
## Bulgaria 28.7 27.7 40.5 31.8
## Rumania 36.8 35.0 47.4 39.7
## Russia (Soviet Union) 31.1 26.9 31.3 27.4
## Finland 13.5 15.7 16.1 11.2
## Sweden 13.5 24.5 14.9 14.4
## Norway 15.7 15.9 8.7 13.0
## Denmark 19.6 21.8 10.4 17.5
## Turkey (Ottoman Empire) 64.3 44.1 61.9 63.8
## Luxembourg France Switzerland Spain Portugal
## United Kingdom 17.2 12.6 26.6 35.0 28.0
## Ireland 19.6 14.2 29.4 35.0 14.2
## Netherlands 24.8 15.8 32.2 36.6 25.8
## Belgium 17.1 8.9 27.5 32.7 24.9
## Luxembourg 0.0 13.0 16.2 27.8 20.2
## France 13.0 0.0 20.2 24.4 17.0
## Switzerland 16.2 20.2 0.0 26.8 22.8
## Spain 27.8 24.4 26.8 0.0 22.2
## Portugal 20.2 17.0 22.8 22.2 0.0
## German Federal Republic 16.5 14.5 16.1 31.5 23.1
## German Democratic Republic 28.5 31.1 28.3 41.3 32.5
## Poland 25.1 26.1 31.9 23.3 13.1
## Austria 8.6 11.8 13.4 22.4 15.0
## Hungary 19.9 26.3 30.1 23.7 17.9
## Czechoslovakia 20.9 29.3 22.7 28.1 22.9
## Italy/Sardinia 11.6 10.0 20.4 26.6 14.4
## Yugoslavia 55.1 50.3 56.1 33.5 41.5
## Greece 34.9 32.7 36.5 24.5 16.3
## Bulgaria 20.1 26.7 26.9 25.7 19.7
## Rumania 27.0 31.6 30.6 17.4 22.2
## Russia (Soviet Union) 30.9 23.7 41.7 32.9 23.1
## Finland 21.1 10.1 28.5 30.3 16.9
## Sweden 28.9 17.1 36.3 36.5 24.1
## Norway 24.9 15.9 33.7 40.1 22.9
## Denmark 32.8 21.0 39.8 39.6 25.0
## Turkey (Ottoman Empire) 59.5 56.3 60.3 44.3 40.1
## German Federal Republic German Democratic Republic
## United Kingdom 16.1 31.7
## Ireland 22.1 33.3
## Netherlands 29.5 44.5
## Belgium 20.8 35.2
## Luxembourg 16.5 28.5
## France 14.5 31.1
## Switzerland 16.1 28.3
## Spain 31.5 41.3
## Portugal 23.1 32.5
## German Federal Republic 0.0 17.2
## German Democratic Republic 17.2 0.0
## Poland 30.4 28.6
## Austria 16.9 30.3
## Hungary 26.0 20.4
## Czechoslovakia 18.2 14.8
## Italy/Sardinia 21.7 31.1
## Yugoslavia 55.2 64.8
## Greece 37.4 41.4
## Bulgaria 20.4 20.2
## Rumania 32.1 32.9
## Russia (Soviet Union) 29.6 27.4
## Finland 15.6 28.8
## Sweden 22.8 38.6
## Norway 27.0 38.4
## Denmark 29.1 43.7
## Turkey (Ottoman Empire) 60.2 63.0
## Poland Austria Hungary Czechoslovakia Italy/Sardinia
## United Kingdom 34.5 15.4 29.1 32.3 21.6
## Ireland 24.5 18.2 27.1 31.3 14.2
## Netherlands 36.1 25.0 39.7 42.7 21.0
## Belgium 31.4 17.7 30.4 34.8 16.1
## Luxembourg 25.1 8.6 19.9 20.9 11.6
## France 26.1 11.8 26.3 29.3 10.0
## Switzerland 31.9 13.4 30.1 22.7 20.4
## Spain 23.3 22.4 23.7 28.1 26.6
## Portugal 13.1 15.0 17.9 22.9 14.4
## German Federal Republic 30.4 16.9 26.0 18.2 21.7
## German Democratic Republic 28.6 30.3 20.4 14.8 31.1
## Poland 0.0 21.1 9.8 14.4 22.3
## Austria 21.1 0.0 16.7 20.3 14.2
## Hungary 9.8 16.7 0.0 9.2 22.3
## Czechoslovakia 14.4 20.3 9.2 0.0 25.3
## Italy/Sardinia 22.3 14.2 22.3 25.3 0.0
## Yugoslavia 38.8 49.5 47.8 52.8 55.3
## Greece 21.4 28.7 27.0 32.4 29.5
## Bulgaria 11.0 19.5 9.4 7.6 22.1
## Rumania 13.7 23.8 15.7 18.7 27.0
## Russia (Soviet Union) 14.0 29.9 19.2 23.8 23.7
## Finland 24.4 17.5 25.2 30.6 18.7
## Sweden 32.0 26.7 35.0 39.0 26.5
## Norway 32.8 22.9 34.4 39.6 22.5
## Denmark 35.7 30.2 38.9 42.9 30.0
## Turkey (Ottoman Empire) 36.4 54.3 45.8 50.8 51.5
## Yugoslavia Greece Bulgaria Rumania
## United Kingdom 57.3 41.7 28.7 36.8
## Ireland 43.7 20.9 27.7 35.0
## Netherlands 54.3 36.1 40.5 47.4
## Belgium 57.2 38.2 31.8 39.7
## Luxembourg 55.1 34.9 20.1 27.0
## France 50.3 32.7 26.7 31.6
## Switzerland 56.1 36.5 26.9 30.6
## Spain 33.5 24.5 25.7 17.4
## Portugal 41.5 16.3 19.7 22.2
## German Federal Republic 55.2 37.4 20.4 32.1
## German Democratic Republic 64.8 41.4 20.2 32.9
## Poland 38.8 21.4 11.0 13.7
## Austria 49.5 28.7 19.5 23.8
## Hungary 47.8 27.0 9.4 15.7
## Czechoslovakia 52.8 32.4 7.6 18.7
## Italy/Sardinia 55.3 29.5 22.1 27.0
## Yugoslavia 0.0 27.8 47.2 36.1
## Greece 27.8 0.0 28.6 23.7
## Bulgaria 47.2 28.6 0.0 14.1
## Rumania 36.1 23.7 14.1 0.0
## Russia (Soviet Union) 48.6 32.6 18.4 22.7
## Finland 49.6 30.4 27.6 36.1
## Sweden 56.0 37.6 34.8 43.3
## Norway 55.4 32.6 37.2 44.3
## Denmark 53.3 33.7 39.5 47.2
## Turkey (Ottoman Empire) 31.6 27.6 44.2 32.9
## Russia (Soviet Union) Finland Sweden Norway Denmark
## United Kingdom 31.1 13.5 13.5 15.7 19.6
## Ireland 26.9 15.7 24.5 15.9 21.8
## Netherlands 31.3 16.1 14.9 8.7 10.4
## Belgium 27.4 11.2 14.4 13.0 17.5
## Luxembourg 30.9 21.1 28.9 24.9 32.8
## France 23.7 10.1 17.1 15.9 21.0
## Switzerland 41.7 28.5 36.3 33.7 39.8
## Spain 32.9 30.3 36.5 40.1 39.6
## Portugal 23.1 16.9 24.1 22.9 25.0
## German Federal Republic 29.6 15.6 22.8 27.0 29.1
## German Democratic Republic 27.4 28.8 38.6 38.4 43.7
## Poland 14.0 24.4 32.0 32.8 35.7
## Austria 29.9 17.5 26.7 22.9 30.2
## Hungary 19.2 25.2 35.0 34.4 38.9
## Czechoslovakia 23.8 30.6 39.0 39.6 42.9
## Italy/Sardinia 23.7 18.7 26.5 22.5 30.0
## Yugoslavia 48.6 49.6 56.0 55.4 53.3
## Greece 32.6 30.4 37.6 32.6 33.7
## Bulgaria 18.4 27.6 34.8 37.2 39.5
## Rumania 22.7 36.1 43.3 44.3 47.2
## Russia (Soviet Union) 0.0 19.6 28.4 24.2 31.5
## Finland 19.6 0.0 10.4 13.4 15.5
## Sweden 28.4 10.4 0.0 16.2 6.9
## Norway 24.2 13.4 16.2 0.0 12.5
## Denmark 31.5 15.5 6.9 12.5 0.0
## Turkey (Ottoman Empire) 44.8 54.8 61.6 58.4 59.5
## Turkey (Ottoman Empire)
## United Kingdom 64.3
## Ireland 44.1
## Netherlands 61.9
## Belgium 63.8
## Luxembourg 59.5
## France 56.3
## Switzerland 60.3
## Spain 44.3
## Portugal 40.1
## German Federal Republic 60.2
## German Democratic Republic 63.0
## Poland 36.4
## Austria 54.3
## Hungary 45.8
## Czechoslovakia 50.8
## Italy/Sardinia 51.5
## Yugoslavia 31.6
## Greece 27.6
## Bulgaria 44.2
## Rumania 32.9
## Russia (Soviet Union) 44.8
## Finland 54.8
## Sweden 61.6
## Norway 58.4
## Denmark 59.5
## Turkey (Ottoman Empire) 0.0
Cophenetic Corellation
#Perbandingan korelasi cophenetic antar metode hirarki
#Single
d1=dist(datacl,method="manhattan", p = 2)
hc= hclust(d1, "single")
d2= cophenetic(hc)
cor.sing = cor (d1,d2)
cor.sing ## [1] 0.7904421
#Average
d1=dist(datacl,method="manhattan", p = 2)
hc= hclust(d1, "ave")
d2= cophenetic(hc)
cor.ave = cor (d1,d2)
cor.ave ## [1] 0.8487
#Complete
d1=dist(datacl,method="manhattan", p = 2)
hc= hclust(d1, "complete")
d2= cophenetic(hc)
cor.comp = cor (d1,d2)
cor.comp## [1] 0.7588813
#Ward
d1 <- dist(datacl,method="manhattan", p = 2)
hc <- hclust(d1, "ward.D")
d2 <- cophenetic(hc)
corward=cor(d1, d2)
corward## [1] 0.4850841
#Centroid
d1 <- dist(datacl,method="manhattan", p = 2)
hc <- hclust(d1, "centroid")
d2 <- cophenetic(hc)
corcent=cor(d1, d2)
corcent## [1] 0.8145719
Berdasarkan Cophenetic Corellation, jika menggunakan matriks jarak Manhattan tidak di standarisasi didapatkan bahwa nilai tertinggi diperoleh jika menggunakan average linkage, yaitu sebesar 0.8487.
Manhattan Distance Matrix (standarized)
mhtn.st <- dist(scale(datacl),method="manhattan", p = 2)
mhtn_st_matrix <- as.matrix(mhtn.st)
mhtn_st_matrix## United Kingdom Ireland Netherlands Belgium
## United Kingdom 0.000000 4.767327 6.274318 4.488326
## Ireland 4.767327 0.000000 6.758544 5.930244
## Netherlands 6.274318 6.758544 0.000000 3.871218
## Belgium 4.488326 5.930244 3.871218 0.000000
## Luxembourg 7.048450 7.287261 7.920126 6.101492
## France 5.014636 4.781720 4.510355 2.780393
## Switzerland 8.161964 7.931167 6.413479 6.621259
## Spain 11.151225 10.676585 9.146877 9.031317
## Portugal 9.042654 5.359839 7.472769 7.022196
## German Federal Republic 4.364269 5.176846 7.819824 5.004385
## German Democratic Republic 9.001563 8.582119 13.318579 10.459818
## Poland 9.927165 7.842731 10.392764 8.218923
## Austria 4.007368 4.616797 6.535943 4.936946
## Hungary 10.081820 9.642047 14.029983 11.171222
## Czechoslovakia 9.275310 8.475166 11.723806 9.760197
## Italy/Sardinia 8.898666 6.144297 6.528136 6.353646
## Yugoslavia 13.410836 12.264022 15.108886 14.708155
## Greece 10.583163 6.247035 8.994423 8.253042
## Bulgaria 8.970487 8.170343 11.471796 8.656357
## Rumania 11.364900 10.105018 13.296570 11.088818
## Russia (Soviet Union) 11.137632 9.901705 10.659473 8.998191
## Finland 4.214333 4.432831 5.485449 4.142746
## Sweden 4.962731 6.738207 4.609739 3.866765
## Norway 7.283539 6.821618 4.737204 4.406061
## Denmark 7.377880 7.618614 3.742790 4.492820
## Turkey (Ottoman Empire) 18.748089 14.709986 19.255172 18.307615
## Luxembourg France Switzerland Spain Portugal
## United Kingdom 7.048450 5.014636 8.161964 11.151225 9.042654
## Ireland 7.287261 4.781720 7.931167 10.676585 5.359839
## Netherlands 7.920126 4.510355 6.413479 9.146877 7.472769
## Belgium 6.101492 2.780393 6.621259 9.031317 7.022196
## Luxembourg 0.000000 5.017609 5.554476 9.262302 7.342153
## France 5.017609 0.000000 4.175400 6.421987 4.849489
## Switzerland 5.554476 4.175400 0.000000 6.942669 5.235779
## Spain 9.262302 6.421987 6.942669 0.000000 6.950498
## Portugal 7.342153 4.849489 5.235779 6.950498 0.000000
## German Federal Republic 5.553915 3.884401 5.104315 8.884014 6.276613
## German Democratic Republic 8.804242 10.920897 11.511446 14.463111 11.134677
## Poland 6.777800 7.977189 9.750263 9.392027 6.095887
## Austria 5.268551 4.259799 5.345753 8.576347 6.626908
## Hungary 8.596519 11.632301 13.128170 13.083871 10.411139
## Czechoslovakia 6.360218 9.326124 9.343138 10.982686 8.674565
## Italy/Sardinia 5.964866 4.170068 5.106804 7.431272 3.928632
## Yugoslavia 15.705922 13.127222 15.194135 11.213820 13.255073
## Greece 9.534739 7.760740 8.384861 7.639966 3.529780
## Bulgaria 6.963018 8.398771 8.885302 9.079968 5.875625
## Rumania 7.856553 8.786215 9.080654 7.305735 6.188413
## Russia (Soviet Union) 10.040818 8.872815 11.653163 10.763317 7.760699
## Finland 8.809583 4.866946 7.861333 10.370951 6.553118
## Sweden 8.456912 4.689577 7.508663 9.530832 6.069307
## Norway 8.158592 5.361371 7.844088 11.251748 6.913516
## Denmark 9.535152 5.767818 8.174550 9.808582 5.566021
## Turkey (Ottoman Empire) 18.870646 16.377983 17.208279 15.212185 12.353199
## German Federal Republic German Democratic Republic
## United Kingdom 4.364269 9.001563
## Ireland 5.176846 8.582119
## Netherlands 7.819824 13.318579
## Belgium 5.004385 10.459818
## Luxembourg 5.553915 8.804242
## France 3.884401 10.920897
## Switzerland 5.104315 11.511446
## Spain 8.884014 14.463111
## Portugal 6.276613 11.134677
## German Federal Republic 0.000000 7.401108
## German Democratic Republic 7.401108 0.000000
## Poland 7.798499 7.045678
## Austria 5.379696 8.866326
## Hungary 10.611202 5.326174
## Czechoslovakia 7.228864 3.912777
## Italy/Sardinia 7.225460 11.780495
## Yugoslavia 12.899170 17.367307
## Greece 8.248320 11.243360
## Bulgaria 6.242486 7.014189
## Rumania 8.805035 10.098046
## Russia (Soviet Union) 9.389665 8.807357
## Finland 5.079067 8.076204
## Sweden 5.005328 11.400305
## Norway 7.593613 11.110464
## Denmark 7.386368 12.985533
## Turkey (Ottoman Empire) 16.468197 19.703968
## Poland Austria Hungary Czechoslovakia
## United Kingdom 9.927165 4.007368 10.081820 9.275310
## Ireland 7.842731 4.616797 9.642047 8.475166
## Netherlands 10.392764 6.535943 14.029983 11.723806
## Belgium 8.218923 4.936946 11.171222 9.760197
## Luxembourg 6.777800 5.268551 8.596519 6.360218
## France 7.977189 4.259799 11.632301 9.326124
## Switzerland 9.750263 5.345753 13.128170 9.343138
## Spain 9.392027 8.576347 13.083871 10.982686
## Portugal 6.095887 6.626908 10.411139 8.674565
## German Federal Republic 7.798499 5.379696 10.611202 7.228864
## German Democratic Republic 7.045678 8.866326 5.326174 3.912777
## Poland 0.000000 7.411282 5.321514 3.497513
## Austria 7.411282 0.000000 7.782417 6.573212
## Hungary 5.321514 7.782417 0.000000 4.077451
## Czechoslovakia 3.497513 6.573212 4.077451 0.000000
## Italy/Sardinia 8.279636 6.763799 11.906209 9.600032
## Yugoslavia 12.570930 14.006769 16.586150 15.005224
## Greece 6.393475 8.100829 10.641359 9.147860
## Bulgaria 3.293365 7.759740 6.718056 4.161564
## Rumania 4.521902 9.203071 8.730365 6.399054
## Russia (Soviet Union) 5.703287 9.740141 9.093067 8.136794
## Finland 8.780726 4.775470 9.516832 9.212349
## Sweden 8.972258 7.368313 12.840932 11.142442
## Norway 9.809036 6.968763 12.396801 11.649491
## Denmark 9.937112 8.159087 13.696937 12.020642
## Turkey (Ottoman Empire) 13.773110 18.155401 18.851550 17.270624
## Italy/Sardinia Yugoslavia Greece Bulgaria
## United Kingdom 8.898666 13.41084 10.583163 8.970487
## Ireland 6.144297 12.26402 6.247035 8.170343
## Netherlands 6.528136 15.10889 8.994423 11.471796
## Belgium 6.353646 14.70815 8.253042 8.656357
## Luxembourg 5.964866 15.70592 9.534739 6.963018
## France 4.170068 13.12722 7.760740 8.398771
## Switzerland 5.106804 15.19413 8.384861 8.885302
## Spain 7.431272 11.21382 7.639966 9.079968
## Portugal 3.928632 13.25507 3.529780 5.875625
## German Federal Republic 7.225460 12.89917 8.248320 6.242486
## German Democratic Republic 11.780495 17.36731 11.243360 7.014189
## Poland 8.279636 12.57093 6.393475 3.293365
## Austria 6.763799 14.00677 8.100829 7.759740
## Hungary 11.906209 16.58615 10.641359 6.718056
## Czechoslovakia 9.600032 15.00522 9.147860 4.161564
## Italy/Sardinia 0.000000 16.56518 6.626099 7.077850
## Yugoslavia 16.565176 0.00000 11.376408 13.732085
## Greece 6.626099 11.37641 0.000000 5.984308
## Bulgaria 7.077850 13.73208 5.984308 0.000000
## Rumania 7.465294 11.48279 6.634811 3.852517
## Russia (Soviet Union) 7.947935 15.73161 8.233994 5.378727
## Finland 8.268354 13.73327 8.074780 9.338725
## Sweden 7.915683 14.24491 7.590969 8.854914
## Norway 7.617363 16.66845 7.994278 10.500191
## Denmark 7.930704 15.22105 6.766360 9.443511
## Turkey (Ottoman Empire) 14.347815 11.46685 10.524310 13.339437
## Rumania Russia (Soviet Union) Finland Sweden
## United Kingdom 11.364900 11.137632 4.214333 4.962731
## Ireland 10.105018 9.901705 4.432831 6.738207
## Netherlands 13.296570 10.659473 5.485449 4.609739
## Belgium 11.088818 8.998191 4.142746 3.866765
## Luxembourg 7.856553 10.040818 8.809583 8.456912
## France 8.786215 8.872815 4.866946 4.689577
## Switzerland 9.080654 11.653163 7.861333 7.508663
## Spain 7.305735 10.763317 10.370951 9.530832
## Portugal 6.188413 7.760699 6.553118 6.069307
## German Federal Republic 8.805035 9.389665 5.079067 5.005328
## German Democratic Republic 10.098046 8.807357 8.076204 11.400305
## Poland 4.521902 5.703287 8.780726 8.972258
## Austria 9.203071 9.740141 4.775470 7.368313
## Hungary 8.730365 9.093067 9.516832 12.840932
## Czechoslovakia 6.399054 8.136794 9.212349 11.142442
## Italy/Sardinia 7.465294 7.947935 8.268354 7.915683
## Yugoslavia 11.482786 15.731606 13.733272 14.244907
## Greece 6.634811 8.233994 8.074780 7.590969
## Bulgaria 3.852517 5.378727 9.338725 8.854914
## Rumania 0.000000 6.800515 12.135798 11.651987
## Russia (Soviet Union) 6.800515 0.000000 8.985062 9.651115
## Finland 12.135798 8.985062 0.000000 3.455241
## Sweden 11.651987 9.651115 3.455241 0.000000
## Norway 12.446502 6.823765 5.203468 5.034271
## Denmark 11.754434 9.293824 5.196117 2.561146
## Turkey (Ottoman Empire) 11.072662 15.001641 17.484768 16.757882
## Norway Denmark Turkey (Ottoman Empire)
## United Kingdom 7.283539 7.377880 18.74809
## Ireland 6.821618 7.618614 14.70999
## Netherlands 4.737204 3.742790 19.25517
## Belgium 4.406061 4.492820 18.30761
## Luxembourg 8.158592 9.535152 18.87065
## France 5.361371 5.767818 16.37798
## Switzerland 7.844088 8.174550 17.20828
## Spain 11.251748 9.808582 15.21218
## Portugal 6.913516 5.566021 12.35320
## German Federal Republic 7.593613 7.386368 16.46820
## German Democratic Republic 11.110464 12.985533 19.70397
## Poland 9.809036 9.937112 13.77311
## Austria 6.968763 8.159087 18.15540
## Hungary 12.396801 13.696937 18.85155
## Czechoslovakia 11.649491 12.020642 17.27062
## Italy/Sardinia 7.617363 7.930704 14.34782
## Yugoslavia 16.668452 15.221045 11.46685
## Greece 7.994278 6.766360 10.52431
## Bulgaria 10.500191 9.443511 13.33944
## Rumania 12.446502 11.754434 11.07266
## Russia (Soviet Union) 6.823765 9.293824 15.00164
## Finland 5.203468 5.196117 17.48477
## Sweden 5.034271 2.561146 16.75788
## Norway 0.000000 4.682420 18.25503
## Denmark 4.682420 0.000000 17.02711
## Turkey (Ottoman Empire) 18.255027 17.027109 0.00000
Cophenetic Corellation
#Perbandingan korelasi cophenetic antar metode hirarki
#Single
d1 <- mhtn.st
hc= hclust(d1, "single")
d2= cophenetic(hc)
cor.sing = cor (d1,d2)
cor.sing ## [1] 0.8365194
## [1] 0.8749918
## [1] 0.8357122
## [1] 0.6477824
## [1] 0.8215919
Berdasarkan Cophenetic Corellation, jika menggunakan matriks jarak Manhattan yang di standarisasi didapatkan bahwa nilai tertinggi juga diperoleh jika menggunakan average linkage, yaitu sebesar 0.8749918. Namun nilai ini tidak lebih besar jika dibandingkan dengan matriks jarak euclidean yang distandarisasi, oleh karena itu untuk analisis selanjutnya digunakan matriks jarak euclidean dengan menggunakan metode average linkage
Dendogram
##
## Call:
## hclust(d = euc.st, method = "average")
##
## Cluster method : average
## Distance : euclidean
## Number of objects: 26
Hasil clustering menggunakan metode hierarki dengan matriks jarak
Euclidean dan metode average linkage menunjukkan adanya indikasi
pembentukan tiga klaster yang potensial berdasarkan dendrogram yang
dihasilkan. Namun, ketika menggunakan fungsi DIANA, terdapat indikasi
bahwa jumlah klaster yang optimal adalah empat.
Non-Hierarchical Clustering
K-Means Clustering
## Min Man PS Con SI Fin SPS TC
## United Kingdom 1.4 30.2 1.4 6.9 16.9 5.7 28.3 6.4
## Ireland 1.0 20.7 1.3 7.5 16.8 2.8 20.8 6.1
## Netherlands 0.1 22.5 1.0 9.9 18.0 6.8 28.5 6.8
## Belgium 0.9 27.6 0.9 8.2 19.1 6.2 26.6 7.2
## Luxembourg 3.1 30.8 0.8 9.2 18.5 4.6 19.2 6.2
## France 0.8 27.5 0.9 8.9 16.8 6.0 22.6 5.7
## Switzerland 0.2 37.8 0.8 9.5 17.5 5.3 15.4 5.7
## Spain 0.8 28.5 0.7 11.5 9.7 8.5 11.8 5.5
## Portugal 0.3 24.5 0.6 8.4 13.3 2.7 16.7 5.7
## German Federal Republic 1.3 35.8 0.9 7.3 14.4 5.0 22.3 6.1
## German Democratic Republic 2.9 41.2 1.3 7.6 11.2 1.2 22.1 8.4
## Poland 2.5 25.7 0.9 8.4 7.5 0.9 16.1 6.9
## Austria 1.1 30.2 1.4 9.0 16.8 4.9 16.8 7.0
## Hungary 3.1 29.6 1.9 8.2 9.4 0.9 17.2 8.0
## Czechoslovakia 2.9 35.5 1.2 8.7 9.2 0.9 17.9 7.0
## Italy/Sardinia 0.6 27.6 0.5 10.0 18.1 1.6 20.1 5.7
## Yugoslavia 1.5 16.8 1.1 4.9 6.4 11.3 5.3 4.0
## Greece 0.6 17.6 0.6 8.1 11.5 2.4 11.0 6.7
## Bulgaria 1.9 32.3 0.6 7.9 8.0 0.7 18.2 6.7
## Rumania 2.1 30.1 0.6 8.7 5.9 1.3 11.7 5.0
## Russia (Soviet Union) 1.4 25.8 0.6 9.2 6.1 0.5 23.6 9.3
## Finland 0.4 25.9 1.3 7.4 14.7 5.5 24.3 7.6
## Sweden 0.4 25.9 0.8 7.2 14.4 6.0 32.4 6.8
## Norway 0.5 22.4 0.8 8.6 16.9 4.7 27.6 9.4
## Denmark 0.1 21.8 0.6 8.3 14.6 6.5 32.2 7.1
## Turkey (Ottoman Empire) 0.7 7.9 0.1 2.8 5.2 1.1 11.9 3.2
## Min Man PS Con SI
## -3.416071e-17 1.878839e-16 -1.503071e-15 8.881784e-16 1.110223e-16
## Fin SPS TC
## -1.708035e-17 -1.708035e-16 -4.440892e-16
## Min Man PS Con SI Fin SPS TC
## 1 1 1 1 1 1 1 1
## K-means clustering with 3 clusters of sizes 2, 17, 7
##
## Cluster means:
## Min Man PS Con SI Fin SPS
## 1 -0.1585972 -2.09163650 -0.81786082 -2.6223997 -1.564436 0.7838767 -1.6725978
## 2 -0.4678616 -0.01536757 -0.02044652 0.2533859 0.613521 0.3604995 0.3118605
## 3 1.1815488 0.63493168 0.28333036 0.1338913 -1.042998 -1.0994635 -0.2794904
## TC
## 1 -2.11729825
## 2 0.01756015
## 3 0.56229629
##
## Clustering vector:
## United Kingdom Ireland
## 2 2
## Netherlands Belgium
## 2 2
## Luxembourg France
## 2 2
## Switzerland Spain
## 2 2
## Portugal German Federal Republic
## 2 2
## German Democratic Republic Poland
## 3 3
## Austria Hungary
## 2 3
## Czechoslovakia Italy/Sardinia
## 3 2
## Yugoslavia Greece
## 1 2
## Bulgaria Rumania
## 3 3
## Russia (Soviet Union) Finland
## 3 2
## Sweden Norway
## 2 2
## Denmark Turkey (Ottoman Empire)
## 2 1
##
## Within cluster sum of squares by cluster:
## [1] 12.76425 69.45532 25.99441
## (between_SS / total_SS = 45.9 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss" "tot.withinss"
## [6] "betweenss" "size" "iter" "ifault"
kmeans3 <- eclust(datacl,stand = TRUE,FUNcluster = "kmeans",k=3,graph = T, nstart = 1, iter.max = 100)## United Kingdom Ireland
## 2 2
## Netherlands Belgium
## 2 2
## Luxembourg France
## 2 2
## Switzerland Spain
## 2 2
## Portugal German Federal Republic
## 2 2
## German Democratic Republic Poland
## 3 3
## Austria Hungary
## 2 3
## Czechoslovakia Italy/Sardinia
## 3 2
## Yugoslavia Greece
## 1 2
## Bulgaria Rumania
## 3 3
## Russia (Soviet Union) Finland
## 3 2
## Sweden Norway
## 2 2
## Denmark Turkey (Ottoman Empire)
## 2 1
##
## 1 2 3
## 2 17 7
## Min Man PS Con SI Fin SPS
## 1 -0.1585972 -2.09163650 -0.81786082 -2.6223997 -1.564436 0.7838767 -1.6725978
## 2 -0.4678616 -0.01536757 -0.02044652 0.2533859 0.613521 0.3604995 0.3118605
## 3 1.1815488 0.63493168 0.28333036 0.1338913 -1.042998 -1.0994635 -0.2794904
## TC
## 1 -2.11729825
## 2 0.01756015
## 3 0.56229629
## cluster Min Man PS Con SI Fin SPS TC
## 1 1 1.1 12.35000 0.600000 3.850000 5.800000 6.2000000 8.60000 3.600000
## 2 2 0.8 26.90000 0.900000 8.582353 15.764706 5.0117647 22.15294 6.570588
## 3 3 2.4 31.45714 1.014286 8.385714 8.185714 0.9142857 18.11429 7.328571
set.seed(123)
res_kmeans <- cluster_analysis(datacl,
n = 3,
method = "kmeans", standardize = TRUE
)
predict(res_kmeans)## [1] 2 2 2 2 2 2 2 2 2 2 3 3 2 3 3 2 1 2 3 3 3 2 2 2 2 1
K-Means Partition Quality
## [1] 91.78601
## [1] 200
## [1] 45.89301
kmeans4 <- eclust(datacl,stand = TRUE,FUNcluster = "kmeans",k=4,graph = T, nstart = 1, iter.max = 100)## [1] 106.3758
## [1] 200
## [1] 53.18788
kmeans5 <- eclust(datacl,stand = TRUE,FUNcluster = "kmeans",k=5,graph = T, nstart = 1, iter.max = 100)## [1] 124.1783
## [1] 200
## [1] 62.08913
Optimal Cluster Determination
Elbow Method
fviz_nbclust(dataclsc, kmeans, method = "wss") + geom_vline(xintercept=4,linetype = 2) + labs(subtitle = "Elbow method") Silhouette Method
Gap Statistic Method
set.seed(123)
fviz_nbclust(dataclsc, kmeans,
nstart = 25,
method = "gap_stat",
nboot = 500 # reduce it for lower computation time (but less precise results)
) +
labs(subtitle = "Gap statistic method")Consensus-based Algorithm
n_clust <- n_clusters(datacl,
package = c("easystats", "NbClust", "mclust"),
standardize = TRUE
)
n_clust## # Method Agreement Procedure:
##
## The choice of 3 clusters is supported by 14 (48.28%) methods out of 29 (Elbow, Ch, Hartigan, CCC, Scott, Marriot, trcovw, Tracew, Ratkowsky, Ball, Frey, Mixture (EII), Mixture (EEI), Mixture (VII)).
Cluster Evaluation
set.seed(123)
km_res <- eclust(datacl,stand = TRUE,FUNcluster = "kmeans",k=3,graph = F)
sil <- silhouette(km_res$cluster, dist(scale(datacl)))
fviz_silhouette(sil)## cluster size ave.sil.width
## 1 1 2 0.16
## 2 2 17 0.28
## 3 3 7 0.30
## Too few points to calculate an ellipse
set.seed(123)
km_res <- eclust(datacl,stand = TRUE,FUNcluster = "kmeans",k=4,graph = F)
sil <- silhouette(km_res$cluster, dist(scale(datacl)))
fviz_silhouette(sil)## cluster size ave.sil.width
## 1 1 5 0.21
## 2 2 2 0.10
## 3 3 3 0.39
## 4 4 16 0.23
sil_df <- as.data.frame(sil)
# Lihat beberapa observasi dengan silhouette negatif
neg_sil <- sil_df[sil_df$sil_width < 0, ]
# Tampilkan hasil
which(sil_df$sil_width < 0)## [1] 9
## Too few points to calculate an ellipse
## Too few points to calculate an ellipse
oke jadinya pake 3
K-Medoids
## Medoids:
## ID Min Man PS Con
## France 6 -0.4678616 0.07025176 -0.02044652 0.4464156
## Poland 12 1.2846369 -0.18660625 -0.02044652 0.1425725
## Turkey (Ottoman Empire) 26 -0.5709497 -2.72664658 -2.14688465 -3.2604702
## SI Fin SPS TC
## France 0.8398023 0.7126152 0.3773200 -0.6081013
## Poland -1.1928723 -1.1045536 -0.5744275 0.2542969
## Turkey (Ottoman Empire) -1.6955767 -1.0332921 -1.1894029 -2.4047643
## Clustering vector:
## United Kingdom Ireland
## 1 1
## Netherlands Belgium
## 1 1
## Luxembourg France
## 1 1
## Switzerland Spain
## 1 1
## Portugal German Federal Republic
## 1 1
## German Democratic Republic Poland
## 2 2
## Austria Hungary
## 1 2
## Czechoslovakia Italy/Sardinia
## 2 1
## Yugoslavia Greece
## 3 2
## Bulgaria Rumania
## 2 2
## Russia (Soviet Union) Finland
## 2 1
## Sweden Norway
## 1 1
## Denmark Turkey (Ottoman Empire)
## 1 3
## Objective function:
## build swap
## 2.052053 2.052053
##
## Available components:
## [1] "medoids" "id.med" "clustering" "objective" "isolation"
## [6] "clusinfo" "silinfo" "diss" "call" "data"
## Min Man PS Con
## France -0.4678616 0.07025176 -0.02044652 0.4464156
## Poland 1.2846369 -0.18660625 -0.02044652 0.1425725
## Turkey (Ottoman Empire) -0.5709497 -2.72664658 -2.14688465 -3.2604702
## SI Fin SPS TC
## France 0.8398023 0.7126152 0.3773200 -0.6081013
## Poland -1.1928723 -1.1045536 -0.5744275 0.2542969
## Turkey (Ottoman Empire) -1.6955767 -1.0332921 -1.1894029 -2.4047643
## United Kingdom Ireland
## 1 1
## Netherlands Belgium
## 1 1
## Luxembourg France
## 1 1
## Switzerland Spain
## 1 1
## Portugal German Federal Republic
## 1 1
## German Democratic Republic Poland
## 2 2
## Austria Hungary
## 1 2
## Czechoslovakia Italy/Sardinia
## 2 1
## Yugoslavia Greece
## 3 2
## Bulgaria Rumania
## 2 2
## Russia (Soviet Union) Finland
## 2 1
## Sweden Norway
## 1 1
## Denmark Turkey (Ottoman Empire)
## 1 3
Evaluation
CH Index
## [1] 9.754184
## [1] 9.371403
DB Index
## [1] 1.181928
## [1] 1.264939
ASW
## cluster size ave.sil.width
## 1 1 2 0.16
## 2 2 17 0.28
## 3 3 7 0.30
## cluster size ave.sil.width
## 1 1 16 0.29
## 2 2 8 0.23
## 3 3 2 0.15
clust.eval<-data.frame(
Method=c("K-Means", "K-Medoids"),
CH=c(ch.km, ch.pam),
DB=c(db.km, db.pam),
ASW=c(colMeans(sil.km$data[3]), colMeans(sil.pam$data[3]))
)
clust.eval## Method CH DB ASW
## 1 K-Means 9.754184 1.181928 0.2780839
## 2 K-Medoids 9.371403 1.264939 0.2610031
oke jadi k-means
Conclusion
## K-means clustering with 3 clusters of sizes 17, 7, 2
##
## Cluster means:
## Min Man PS Con SI Fin SPS
## 1 -0.4678616 -0.01536757 -0.02044652 0.2533859 0.613521 0.3604995 0.3118605
## 2 1.1815488 0.63493168 0.28333036 0.1338913 -1.042998 -1.0994635 -0.2794904
## 3 -0.1585972 -2.09163650 -0.81786082 -2.6223997 -1.564436 0.7838767 -1.6725978
## TC
## 1 0.01756015
## 2 0.56229629
## 3 -2.11729825
##
## Clustering vector:
## United Kingdom Ireland
## 1 1
## Netherlands Belgium
## 1 1
## Luxembourg France
## 1 1
## Switzerland Spain
## 1 1
## Portugal German Federal Republic
## 1 1
## German Democratic Republic Poland
## 2 2
## Austria Hungary
## 1 2
## Czechoslovakia Italy/Sardinia
## 2 1
## Yugoslavia Greece
## 3 1
## Bulgaria Rumania
## 2 2
## Russia (Soviet Union) Finland
## 2 1
## Sweden Norway
## 1 1
## Denmark Turkey (Ottoman Empire)
## 1 3
##
## Within cluster sum of squares by cluster:
## [1] 69.45532 25.99441 12.76425
## (between_SS / total_SS = 45.9 %)
##
## Available components:
##
## [1] "cluster" "centers" "totss" "withinss" "tot.withinss"
## [6] "betweenss" "size" "iter" "ifault"
cluster_df <- data.frame(
country_name = names(cluster_best$cluster),
cluster = as.factor(cluster_best$cluster) # Pakai factor biar enak visualisasinya nanti
)
mapdata_best <- cs_europe_1979 %>%
left_join(cluster_df, by = "country_name")
mapdata_best## Simple feature collection with 30 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -180 ymin: 27.6375 xmax: 180 ymax: 77.73221
## Geodetic CRS: WGS 84
## First 10 features:
## gwcode country_name start end status owner
## 1 200 United Kingdom 1921-12-06 2019-12-31 independent 200
## 2 205 Ireland 1921-12-06 2019-12-31 independent 205
## 3 210 Netherlands 1886-01-01 2019-12-31 independent 210
## 4 211 Belgium 1886-01-01 2019-12-31 independent 211
## 5 212 Luxembourg 1886-01-01 2019-12-31 independent 212
## 6 220 France 1919-06-28 2019-12-31 independent 220
## 7 225 Switzerland 1886-01-01 2019-12-31 independent 225
## 8 230 Spain 1886-01-01 2019-12-31 independent 230
## 9 235 Portugal 1886-01-01 2019-12-31 independent 235
## 10 260 German Federal Republic 1949-09-21 1990-10-02 independent 260
## capname caplong caplat b_def fid cluster
## 1 London -0.116667 51.50000 1 74 1
## 2 Dublin -6.248889 53.33306 1 75 1
## 3 Amsterdam 4.916667 52.35000 1 76 1
## 4 Brussels 4.333333 50.83333 1 77 1
## 5 Luxembourg 6.130000 49.61167 1 78 1
## 6 Paris 2.333333 48.86666 1 80 1
## 7 Bern 7.466667 46.91667 1 81 1
## 8 Madrid -3.683333 40.40000 1 82 1
## 9 Lisbon -9.133333 38.71667 1 83 1
## 10 Bonn 7.100000 50.73333 1 89 1
## geometry
## 1 MULTIPOLYGON (((-1.241664 5...
## 2 MULTIPOLYGON (((-7.252509 5...
## 3 MULTIPOLYGON (((7.207575 53...
## 4 MULTIPOLYGON (((6.011798 50...
## 5 MULTIPOLYGON (((6.125963 50...
## 6 MULTIPOLYGON (((9.50739 42....
## 7 MULTIPOLYGON (((9.572112 47...
## 8 MULTIPOLYGON (((-17.96389 2...
## 9 MULTIPOLYGON (((-16.96 32.8...
## 10 MULTIPOLYGON (((8.692773 54...
ggplot(mapdata_best) +
geom_sf(aes(fill = cluster), color = "white", size = 0.2) +
scale_fill_brewer(palette = "Set2", name = "Cluster") +
theme_minimal() +
labs(
title = "Hasil K-Means Clustering Negara Eropa (1979)",
subtitle = "Dikelompokkan berdasarkan persentase populasi pekerja",
caption = "Sumber data: cs_europe_1979 & hasil k-means"
) +
theme(
legend.position = "right",
plot.title = element_text(size = 16, face = "bold"),
plot.subtitle = element_text(size = 12)
)## Simple feature collection with 30 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -180 ymin: 27.6375 xmax: 180 ymax: 77.73221
## Geodetic CRS: WGS 84
## First 10 features:
## gwcode country_name start end status owner
## 1 200 United Kingdom 1921-12-06 2019-12-31 independent 200
## 2 205 Ireland 1921-12-06 2019-12-31 independent 205
## 3 210 Netherlands 1886-01-01 2019-12-31 independent 210
## 4 211 Belgium 1886-01-01 2019-12-31 independent 211
## 5 212 Luxembourg 1886-01-01 2019-12-31 independent 212
## 6 220 France 1919-06-28 2019-12-31 independent 220
## 7 225 Switzerland 1886-01-01 2019-12-31 independent 225
## 8 230 Spain 1886-01-01 2019-12-31 independent 230
## 9 235 Portugal 1886-01-01 2019-12-31 independent 235
## 10 260 German Federal Republic 1949-09-21 1990-10-02 independent 260
## capname caplong caplat b_def fid cluster
## 1 London -0.116667 51.50000 1 74 1
## 2 Dublin -6.248889 53.33306 1 75 1
## 3 Amsterdam 4.916667 52.35000 1 76 1
## 4 Brussels 4.333333 50.83333 1 77 1
## 5 Luxembourg 6.130000 49.61167 1 78 1
## 6 Paris 2.333333 48.86666 1 80 1
## 7 Bern 7.466667 46.91667 1 81 1
## 8 Madrid -3.683333 40.40000 1 82 1
## 9 Lisbon -9.133333 38.71667 1 83 1
## 10 Bonn 7.100000 50.73333 1 89 1
## geometry
## 1 MULTIPOLYGON (((-1.241664 5...
## 2 MULTIPOLYGON (((-7.252509 5...
## 3 MULTIPOLYGON (((7.207575 53...
## 4 MULTIPOLYGON (((6.011798 50...
## 5 MULTIPOLYGON (((6.125963 50...
## 6 MULTIPOLYGON (((9.50739 42....
## 7 MULTIPOLYGON (((9.572112 47...
## 8 MULTIPOLYGON (((-17.96389 2...
## 9 MULTIPOLYGON (((-16.96 32.8...
## 10 MULTIPOLYGON (((8.692773 54...
## Simple feature collection with 30 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -180 ymin: 27.6375 xmax: 180 ymax: 77.73221
## Geodetic CRS: WGS 84
## First 10 features:
## gwcode country_name start end status owner
## 1 200 United Kingdom 1921-12-06 2019-12-31 independent 200
## 2 205 Ireland 1921-12-06 2019-12-31 independent 205
## 3 210 Netherlands 1886-01-01 2019-12-31 independent 210
## 4 211 Belgium 1886-01-01 2019-12-31 independent 211
## 5 212 Luxembourg 1886-01-01 2019-12-31 independent 212
## 6 220 France 1919-06-28 2019-12-31 independent 220
## 7 225 Switzerland 1886-01-01 2019-12-31 independent 225
## 8 230 Spain 1886-01-01 2019-12-31 independent 230
## 9 235 Portugal 1886-01-01 2019-12-31 independent 235
## 10 260 German Federal Republic 1949-09-21 1990-10-02 independent 260
## capname caplong caplat b_def fid cluster
## 1 London -0.116667 51.50000 1 74 1
## 2 Dublin -6.248889 53.33306 1 75 1
## 3 Amsterdam 4.916667 52.35000 1 76 1
## 4 Brussels 4.333333 50.83333 1 77 1
## 5 Luxembourg 6.130000 49.61167 1 78 1
## 6 Paris 2.333333 48.86666 1 80 1
## 7 Bern 7.466667 46.91667 1 81 1
## 8 Madrid -3.683333 40.40000 1 82 1
## 9 Lisbon -9.133333 38.71667 1 83 1
## 10 Bonn 7.100000 50.73333 1 89 1
## geometry
## 1 MULTIPOLYGON (((-1.241664 5...
## 2 MULTIPOLYGON (((-7.252509 5...
## 3 MULTIPOLYGON (((7.207575 53...
## 4 MULTIPOLYGON (((6.011798 50...
## 5 MULTIPOLYGON (((6.125963 50...
## 6 MULTIPOLYGON (((9.50739 42....
## 7 MULTIPOLYGON (((9.572112 47...
## 8 MULTIPOLYGON (((-17.96389 2...
## 9 MULTIPOLYGON (((-16.96 32.8...
## 10 MULTIPOLYGON (((8.692773 54...