Introduction

Cross-country evidence suggests that hours of work tend to decline with income, while inequality may be associated with longer hours within affluent economies (Bick, Fuchs-Schündeln and Lagakos 2018; Bowles and Park 2005; Bell and Freeman 2001). One explanation concerns relative consumption: individuals may increase their labour supply to keep up with others. Another concerns taxation, collective bargaining, working-time regulation and social protection (Prescott 2004; Alesina, Glaeser and Sacerdote 2006). Burgoon and Baxandall (2004), drawing on Esping-Andersen (1990), describe different worlds of working time. The Global Working Hours database (Gethin and Saez 2026) makes it possible to examine these patterns across a much wider set of countries.

Rather than estimating another single relationship between income and hours, this study examines whether countries with similar distributional and employment institutions also display similar working-time outcomes. The institutional typology is constructed without working hours or GDP. Hours are subsequently used to characterise the groups, and GDP provides a benchmark for comparison.

Two hypotheses guide the analysis:

  • H1. Countries with strong redistribution form a distinct regime with short hours per worker, even though their market incomes are as unequal as elsewhere.
  • H2. Long hours per worker go together with a large gender employment gap and informal employment, rather than with market inequality as such.

The analysis does not assume that regimes are discrete categories. Stability analysis, fuzzy membership and consensus clustering provide initial evidence about their boundaries. Part 4 investigates the geometry of the same observations using persistent homology and Mapper, evaluates alternative structures through simulation, and examines the role of geography.

Data

The data come from my master’s thesis. Working hours and employment are from the Global Working Hours database (Gethin and Saez 2026), market and disposable income Gini coefficients from SWIID (Solt 2020). The other variables are social transfers (% of GDP), a working-time regulations index (0–1) and the share of formal employment. 156 countries have SWIID data and enter the analysis.

Seven features describe each country. Three choices deserve comment.

  • Redistribution is measured directly, as the relative reduction of the Gini coefficient by taxes and transfers: \(R = 100\,(G^{market} - G^{disposable}) / G^{market}\). Together with the market Gini it describes inequality without using two almost identical Gini measures.
  • The gender employment gap (male minus female employment rate, in percentage points) replaces female employment, which correlates at about 0.93 with total employment and would count the same thing twice. The gap also captures differences in female labour supply, which vary widely even among rich countries (Blau and Kahn 2013).
  • GDP and working hours are left out. Hours are the outcome to be compared across regimes. GDP is used afterwards to check whether the regimes are more than rich versus poor.

Data quality. The variables come from different survey years. Hours are observed between 2003 and 2023 (median 2022), and for a few countries the latest SWIID estimate is much older than the hours data, for example Brunei (1981) and Somalia (2002). The robustness section repeats the analysis on countries with recent SWIID data only.

Missing values. 19 countries miss the formal employment share and a few miss transfers or regulations. These are mainly poorer countries, so dropping them would bias the sample. They are imputed with predictive mean matching (mice, five imputations; Rubin 1987; van Buuren and Groothuis-Oudshoorn 2011). The main analysis uses the first imputation, and the robustness section checks the other four and the complete cases.

raw <- read.csv("cross_merged.csv")

df <- raw %>%
  transmute(iso3, country = isoname, region, year_hours = year_orig, year_gini = swiid_year,
            hours_worker = w, hours_adult = h, log_gdp = log_agdp,
            employment   = e,
            gender_gap   = e_men - e_wom,
            gini_market  = gini_mkt,
            redistribution = 100 * (gini_mkt - gini_disp) / gini_mkt,
            transfers    = gova_soci,
            regulations  = regulations,
            formal       = ilo_emp_inf_tot) %>%
  filter(!is.na(gini_market))

features <- c("employment", "gender_gap", "gini_market", "redistribution",
              "transfers", "regulations", "formal")

nrow(df)
## [1] 156
colSums(is.na(df[features]))
##     employment     gender_gap    gini_market redistribution      transfers 
##              0              0              0              0              4 
##    regulations         formal 
##              4             19
summary(df[c("year_hours", "year_gini")])
##    year_hours     year_gini   
##  Min.   :2003   Min.   :1981  
##  1st Qu.:2018   1st Qu.:2019  
##  Median :2022   Median :2022  
##  Mean   :2020   Mean   :2020  
##  3rd Qu.:2023   3rd Qu.:2023  
##  Max.   :2023   Max.   :2023
df %>% filter(year_gini < 2013) %>% select(country, year_hours, year_gini)
##             country year_hours year_gini
## 1        Azerbaijan       2015      2008
## 2 Brunei Darussalam       2023      1981
## 3            Guyana       2019      2007
## 4             Haiti       2012      2012
## 5          Cambodia       2019      2012
## 6           Somalia       2017      2002
imp <- mice(df[features], m = 5, method = "pmm", seed = 430559, printFlag = FALSE)
X  <- complete(imp, 1)
Xs <- scale(X); rownames(Xs) <- df$iso3
corrplot(cor(cbind(X, hours_worker = df$hours_worker, hours_adult = df$hours_adult, log_gdp = df$log_gdp)),
         method = "color", type = "upper", addCoef.col = "black", number.cex = 0.6, tl.col = "black")

Hours per worker are lower where redistribution, transfers and formal employment are high, and higher where the gender gap is large. Market inequality is only weakly related to hours. Hours per adult behave differently: they rise with total employment, because they combine how long people work with how many people work. Redistribution, transfers and formal employment are strongly correlated with each other and with GDP, so in the raw features the level of development would be counted three times. This is the reason for clustering on rotated principal components below.

Part 1: Dimension reduction

How many dimensions?

pca <- prcomp(Xs)
summary(pca)
## Importance of components:
##                           PC1    PC2    PC3    PC4     PC5     PC6     PC7
## Standard deviation     1.6596 1.2378 1.0100 0.9765 0.58151 0.51549 0.36874
## Proportion of Variance 0.3935 0.2189 0.1457 0.1362 0.04831 0.03796 0.01942
## Cumulative Proportion  0.3935 0.6123 0.7581 0.8943 0.94261 0.98058 1.00000
eig <- pca$sdev^2

pa <- replicate(500, prcomp(matrix(rnorm(length(Xs)), nrow(Xs)), scale. = TRUE)$sdev^2)
pa95 <- apply(pa, 1, quantile, 0.95)
round(rbind(eigenvalue = eig, parallel_95 = pa95), 2)
##             [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## eigenvalue  2.75 1.53 1.02 0.95 0.34 0.27 0.14
## parallel_95 1.42 1.26 1.14 1.05 0.96 0.89 0.79
plot(eig, type = "b", pch = 19, xlab = "Component", ylab = "Eigenvalue", main = "Scree plot and parallel analysis")
lines(pa95, type = "b", lty = 2, col = "red"); abline(h = 1, lty = 3)
legend("topright", c("data", "random data (95th pct)", "Kaiser = 1"), lty = c(1, 2, 3), col = c(1, 2, 1), bty = "n")

n_pc <- 3
rs <- rotated_scores(Xs, n_pc)
scores <- rs$scores; rownames(scores) <- df$iso3
colnames(scores) <- colnames(rs$loadings) <- c("welfare_state", "employment", "market_inequality")
round(rs$loadings, 2)
##                welfare_state employment market_inequality
## employment             -0.15       0.93             -0.12
## gender_gap             -0.28      -0.80             -0.34
## gini_market             0.07      -0.05              0.88
## redistribution          0.89       0.05              0.26
## transfers               0.87       0.11              0.02
## regulations             0.08       0.09              0.51
## formal                  0.93      -0.09              0.07
fviz_pca_var(pca, repel = TRUE)

The criteria disagree on the number of components. Parallel analysis (Horn 1965), which compares the eigenvalues with those of random data of the same size, keeps two. The Kaiser rule keeps three, with the third eigenvalue just above one. I keep three, because the third component carries market inequality, which the hypotheses are about, and together they explain about three quarters of the variance. The robustness section shows what changes with two.

After varimax rotation the components have a clear meaning:

  • Welfare state: formal employment, redistribution and transfers. It is close to the level of development, but it is measured by institutions, not by income.
  • Employment: high total employment and a small gender gap.
  • Market inequality: the market Gini, with a moderate loading of working-time regulations.

Rotated components of this kind are also the starting point of the PCA chapter in Kopczewska (2027), where they are mapped across regions. The rotation makes the components easier to name, but it does not prove that they are three separate economic mechanisms.

MDS: two or three dimensions?

d <- dist(Xs)
mds2 <- MASS::isoMDS(d, k = 2, trace = FALSE)
mds3 <- MASS::isoMDS(d, k = 3, trace = FALSE)
c(stress_2D = mds2$stress, stress_3D = mds3$stress)
## stress_2D stress_3D 
##  19.94462  11.16400
plot(mds2$points, type = "n", xlab = "Dim 1", ylab = "Dim 2", main = "Non-metric MDS (2D)")
text(mds2$points, labels = rownames(Xs), cex = 0.5)

plot(as.vector(d), as.vector(dist(mds2$points)), pch = ".", xlab = "original distance",
     ylab = "distance on the 2D map", main = "Shepard diagram"); abline(0, 1, col = "red")

Non-metric MDS in two dimensions has a stress of about 19.9%, which is a poor fit. With three dimensions it falls to about 11.2%. This agrees with PCA: the countries cannot be drawn faithfully on a plane, and at least three dimensions are needed.

t-SNE: how stable are the neighbourhoods?

t-SNE (van der Maaten and Hinton 2008) preserves local neighbourhoods rather than global distances, and its result depends on the perplexity parameter.

perp <- c(5, 15, 30, 40)
runs <- lapply(perp, function(p) { set.seed(1); Rtsne(Xs, perplexity = p, check_duplicates = FALSE)$Y })
names(runs) <- paste0("perplexity ", perp)
nn <- function(Y, k = 5) { D <- as.matrix(dist(Y)); t(apply(D, 1, function(r) order(r)[2:(k + 1)])) }
nn_data <- nn(Xs)
round(sapply(runs, function(Y) mean(sapply(1:nrow(Y), function(i) length(intersect(nn(Y)[i, ], nn_data[i, ])) / 5))), 2)
##  perplexity 5 perplexity 15 perplexity 30 perplexity 40 
##          0.63          0.67          0.64          0.60
par(mfrow = c(2, 2), mar = c(1, 1, 2, 1))
for (r in names(runs)) plot(runs[[r]], pch = 19, cex = 0.5, xaxt = "n", yaxt = "n", main = r)

par(mfrow = c(1, 1))

The numbers show which share of each country’s five nearest neighbours in the data stay neighbours on the t-SNE map. Across perplexities from 5 to 40 this share is roughly 0.6–0.7: t-SNE keeps most of the local structure, but the maps differ visibly between settings. I therefore use t-SNE only to look at the data and draw no conclusions from the distances between groups on the map.

Beyond the classes: life-cycle profiles of employment (discretised functional PCA)

The features above describe each country with averages. The data also contain employment rates by five-year age group (15–19 to 65+) separately for men and women, so each country can be described by two curves. Treating these 22 numbers as a function observed at eleven ages and running PCA on them is a discretised version of functional PCA; with only eleven evenly spaced points per curve, smoothing with basis functions is unlikely to change the leading components, so I do not use it: each component is a typical way in which a country’s life-cycle profile departs from the average one. These profiles are not used for clustering; they are compared across the clusters later.

ages <- seq(15, 65, 5)
prof_cols <- c(paste0("e_", ages, "_men"), paste0("e_", ages, "_wom"))
P <- raw[match(df$iso3, raw$iso3), prof_cols]
P <- complete(mice(P, m = 1, method = "pmm", seed = 1, printFlag = FALSE))
fpca <- prcomp(P, scale. = FALSE)
round(summary(fpca)$importance[2:3, 1:4], 2)
##                         PC1  PC2  PC3  PC4
## Proportion of Variance 0.61 0.18 0.09 0.05
## Cumulative Proportion  0.61 0.79 0.88 0.93
mean_curve <- colMeans(P)
par(mfrow = c(1, 2))
for (j in 1:2) {
  shift <- 2 * fpca$sdev[j] * fpca$rotation[, j]
  for (sex in c("men", "wom")) {
    idx <- grep(sex, prof_cols)
    if (sex == "men") plot(ages, mean_curve[idx], type = "l", lwd = 2, ylim = c(0, 100),
                           xlab = "age group", ylab = "employment rate (%)", main = paste0("FPC", j))
    else lines(ages, mean_curve[idx], lwd = 2, col = "red")
    lines(ages, mean_curve[idx] + shift[idx], lty = 2, col = ifelse(sex == "men", "black", "red"))
    lines(ages, mean_curve[idx] - shift[idx], lty = 3, col = ifelse(sex == "men", "black", "red"))
  }
  legend("topright", c("men", "women", "+2 sd", "-2 sd"), col = c(1, 2, 1, 1), lty = c(1, 1, 2, 3), bty = "n", cex = 0.7)
}

par(mfrow = c(1, 1))
df$fpc1 <- fpca$x[, 1]; df$fpc2 <- fpca$x[, 2]

The first functional component explains about 61% of the variation in the profiles. It raises women’s employment at all ages, so it measures how much women take part in paid work across the whole life cycle. The second (about 18%) raises employment at the edges of working life, among the young and among people aged 60 and over, and lowers it slightly for women of prime age. It measures early entry and late exit from work.

As a check on the discretised version, the curves are also smoothed with a B-spline basis and a roughness penalty chosen by generalised cross-validation, and functional PCA is run on the smooth curves, separately for men and women (Ramsay and Silverman 2005).

fd_res <- tryCatch({
  basis <- fda::create.bspline.basis(range(ages), nbasis = 7)
  lapply(c(men = "men", women = "wom"), function(sx) {
    Y <- t(as.matrix(P[, grep(sx, prof_cols)]))
    lams <- 10^seq(-2, 4, 1)
    gcv <- sapply(lams, function(l) sum(fda::smooth.basis(ages, Y, fda::fdPar(basis, 2, l))$gcv))
    fdo <- fda::smooth.basis(ages, Y, fda::fdPar(basis, 2, lams[which.min(gcv)]))$fd
    pf  <- fda::pca.fd(fdo, nharm = 3)
    list(lambda = lams[which.min(gcv)], varprop = round(pf$varprop, 2), scores = pf$scores, harm = pf$harmonics)
  })
}, error = function(e) paste("Smoothed FPCA not computed (install the fda package):", conditionMessage(e)))
if (is.list(fd_res)) {
  print(sapply(fd_res, function(x) c(lambda = x$lambda, x$varprop)))
  print(round(c(cor_women_PC1_with_discrete_FPC1 = abs(cor(fd_res$women$scores[, 1], df$fpc1)),
                cor_men_PC1_with_discrete_FPC2 = abs(cor(fd_res$men$scores[, 1], df$fpc2))), 2))
  par(mfrow = c(1, 2)); plot(fd_res$women$harm[1:2], main = "Women: first two harmonics"); plot(fd_res$men$harm[1:2], main = "Men: first two harmonics"); par(mfrow = c(1, 1))
} else fd_res
##         men women
## lambda 1.00  1.00
##        0.66  0.84
##        0.18  0.08
##        0.10  0.05
## cor_women_PC1_with_discrete_FPC1   cor_men_PC1_with_discrete_FPC2 
##                             0.98                             0.52

For women the first smoothed component explains about 84% of the variation and its scores correlate at about 0.98 with the first discretised component, so smoothing does not change the main result: the dominant difference between countries is how much women work over the whole life cycle. For men the first smoothed component explains about 66% of the variation; it correlates only at about 0.52 with the second discretised component, because the discretised components mix men’s and women’s curves, so the smoothed analysis separates the two sexes more cleanly.

Part 2: Clustering

Working hours are not used to form the clusters. They are compared across clusters only afterwards, so that a “long-hours cluster” cannot appear simply because hours were one of the inputs. Clustering is done on the rotated component scores, which gives each dimension the same weight.

Is there a cluster structure, and how many clusters?

hop <- get_clust_tendency(scores, n = 40, graph = FALSE)$hopkins_stat
## Warning: Hopkins statistic uses the corrected formula (Wright 2022); results
## differ from legacy factoextra. Set options(factoextra.warn_hopkins = FALSE) to
## silence this warning.
hop_ref <- sapply(1:50, function(i) { set.seed(i)
  U <- apply(scores, 2, function(x) runif(length(x), min(x), max(x)))
  get_clust_tendency(U, n = 40, graph = FALSE, seed = i)$hopkins_stat })
c(hopkins_data = hop, reference_median = median(hop_ref), reference_95 = unname(quantile(hop_ref, 0.95)))
##     hopkins_data reference_median     reference_95 
##        0.9021794        0.5003751        0.5979263

The usual indices often disagree, so I add a stability check. I draw 80% of the countries 100 times, cluster them, and compare the result with the full-sample clustering of the same countries (adjusted Rand index). Drawing subsamples to see how much a result depends on the particular observations follows the bootstrap logic discussed in Kopczewska (2027, ch. 10).

ks <- 2:6
crit <- t(sapply(ks, function(k) {
  cl <- kmeans(scores, k, nstart = 50)$cluster
  c(k = k, silhouette = mean(silhouette(cl, dist(scores))[, 3]), CH = ch_index(scores, cl))
}))
gap <- clusGap(scores, FUN = kmeans, nstart = 25, K.max = 6, B = 100)
crit <- cbind(crit, gap = gap$Tab[ks, "gap"])

stab <- sapply(ks, function(k) {
  full <- kmeans(scores, k, nstart = 50)$cluster
  replicate(100, { i <- sample(nrow(scores), round(0.8 * nrow(scores)))
                   ari(kmeans(scores[i, ], k, nstart = 20)$cluster, full[i]) })
})
crit <- cbind(crit, stability_median = apply(stab, 2, median), stability_p10 = apply(stab, 2, quantile, 0.1))
round(crit, 3)
##      k silhouette     CH   gap stability_median stability_p10
## [1,] 2      0.290 58.868 0.317            1.000         0.698
## [2,] 3      0.338 72.212 0.332            0.745         0.377
## [3,] 4      0.354 81.635 0.364            0.706         0.555
## [4,] 5      0.375 88.809 0.395            0.898         0.820
## [5,] 6      0.345 85.429 0.391            0.880         0.657
boxplot(stab, names = paste0("k=", ks), ylab = "ARI with full-sample clustering", main = "Bootstrap stability")

The same question can be asked with the validation measures of Brock et al. (2008), which compare several algorithms at once. Internal measures (connectivity, Dunn index, silhouette) judge how compact and separated the clusters are. Stability measures (APN, AD, ADM, FOM) remove one feature at a time and check how much the partition changes.

cv <- clValid(scores, nClust = 2:6, clMethods = c("kmeans", "pam", "hierarchical"),
              validation = c("internal", "stability"), maxitems = nrow(scores))
optimalScores(cv)
##                  Score       Method Clusters
## APN          0.1200466 hierarchical        2
## AD           1.5367630          pam        6
## ADM          0.3002214 hierarchical        2
## FOM          0.9558872          pam        6
## Connectivity 4.0690476 hierarchical        2
## Dunn         0.2363398 hierarchical        3
## Silhouette   0.3714942          pam        5

The Hopkins statistic for the component scores is about 0.9. Random uniform data of the same size give about 0.5, and at most 0.6 in 95% of cases, so the countries are more clustered than random data. This does not yet show that the clusters are well separated.

Among the k-means criteria five clusters are best: the silhouette, the Calinski-Harabasz index and the gap statistic (Tibshirani, Walther and Hastie 2001) are all highest at k = 5, and the bootstrap stability is high (median ARI about 0.9). Two clusters are even more stable, but they only separate the welfare states from everyone else, and three or four clusters are clearly less stable. The clValid measures, which also compare PAM and hierarchical clustering, do not point to one answer. Connectivity, APN and ADM prefer two hierarchical clusters, the Dunn index three, AD and FOM six PAM clusters, and the silhouette five PAM clusters. Such disagreement is typical when the structure is only moderate. Even at k = 5 the silhouette is moderate, so the five clusters are best read as a useful exploratory typology, not as proof of five separate regimes.

The typology

k <- 5
km <- kmeans(scores, centers = k, nstart = 100)
m <- aggregate(X, list(cl = km$cluster), mean)
lab <- character(k); left <- m$cl
pick <- function(v, high = TRUE) { i <- left[order(m[[v]][match(left, m$cl)], decreasing = high)[1]]; left <<- setdiff(left, i); i }
lab[pick("redistribution")] <- "Redistributive"
lab[pick("employment")]     <- "Informal full-employment"
lab[pick("gender_gap")]     <- "Male-breadwinner"
lab[pick("gini_market")]    <- "High market inequality"
lab[left]                   <- "Low-redistribution, high-employment"
cl_name <- factor(lab[km$cluster], levels = c("Redistributive", "Low-redistribution, high-employment",
                  "High market inequality", "Male-breadwinner", "Informal full-employment"))
pm <- pam(scores, k = k)
hc_cl <- cutree(hclust(dist(scores), method = "ward.D2"), k)
c(silhouette = mean(silhouette(km$cluster, dist(scores))[, 3]),
  ARI_kmeans_PAM = ari(km$cluster, pm$clustering), ARI_kmeans_Ward = ari(km$cluster, hc_cl))
##      silhouette  ARI_kmeans_PAM ARI_kmeans_Ward 
##       0.3748006       0.9269005       0.7238212
fviz_cluster(km, data = scores, repel = TRUE, labelsize = 7, main = "k-means on rotated components")

fviz_silhouette(silhouette(km$cluster, dist(scores)), print.summary = FALSE)

df$cluster <- cl_name
df %>% mutate(across(all_of(features), ~ X[[cur_column()]])) %>%
  group_by(cluster) %>%
  summarise(n = n(), across(all_of(features), ~ round(mean(.x), 1)),
            hours_worker = round(mean(hours_worker), 1), hours_adult = round(mean(hours_adult), 1),
            gdp_thousand = round(exp(mean(log_gdp)) / 1000, 1)) %>% as.data.frame()
##                               cluster  n employment gender_gap gini_market
## 1                      Redistributive 44       58.5       10.6        47.1
## 2 Low-redistribution, high-employment 42       61.6       20.5        39.6
## 3              High market inequality 28       50.0       21.1        51.9
## 4                    Male-breadwinner 20       42.9       42.0        41.6
## 5            Informal full-employment 22       73.4        5.6        45.9
##   redistribution transfers regulations formal hours_worker hours_adult
## 1           35.2       6.4         0.6   94.7         34.6        20.1
## 2            7.0       1.8         0.5   40.4         41.6        25.5
## 3           10.7       1.2         0.6   35.1         42.7        21.2
## 4            6.1       1.7         0.5   37.7         43.9        18.5
## 5            4.5       0.8         0.7    9.1         39.0        28.2
##   gdp_thousand
## 1         64.4
## 2         17.9
## 3         14.9
## 4         13.4
## 5          5.2
df %>% group_by(cluster) %>% summarise(examples = paste(head(sort(country), 8), collapse = ", ")) %>% as.data.frame()
##                               cluster
## 1                      Redistributive
## 2 Low-redistribution, high-employment
## 3              High market inequality
## 4                    Male-breadwinner
## 5            Informal full-employment
##                                                                                  examples
## 1      Albania, Australia, Austria, Belarus, Belgium, Brunei Darussalam, Bulgaria, Canada
## 2              Argentina, Azerbaijan, Bangladesh, Bhutan, Bolivia, Cambodia, Chile, China
## 3   Armenia, Belize, Bosnia and Herzegovina, Botswana, Brazil, Cabo Verde, Chad, Colombia
## 4                    Afghanistan, Costa Rica, Egypt, Guatemala, India, Iran, Iraq, Jordan
## 5 Angola, Benin, Burkina Faso, Burundi, Cameroon, Central African Republic, Ghana, Guinea
table(df$region, df$cluster)
##                                 
##                                  Redistributive
##   East and Southeast Asia                     2
##   Eastern Europe and ex-USSR                 17
##   Latin America                               1
##   Middle East and North Africa                0
##   South Asia                                  0
##   Sub-Saharan Africa                          0
##   United States                               1
##   Western Europe and Anglosphere             23
##                                 
##                                  Low-redistribution, high-employment
##   East and Southeast Asia                                         16
##   Eastern Europe and ex-USSR                                       4
##   Latin America                                                   12
##   Middle East and North Africa                                     2
##   South Asia                                                       2
##   Sub-Saharan Africa                                               6
##   United States                                                    0
##   Western Europe and Anglosphere                                   0
##                                 
##                                  High market inequality Male-breadwinner
##   East and Southeast Asia                             0                1
##   Eastern Europe and ex-USSR                          5                2
##   Latin America                                       9                2
##   Middle East and North Africa                        2               12
##   South Asia                                          0                3
##   Sub-Saharan Africa                                 12                0
##   United States                                       0                0
##   Western Europe and Anglosphere                      0                0
##                                 
##                                  Informal full-employment
##   East and Southeast Asia                               0
##   Eastern Europe and ex-USSR                            0
##   Latin America                                         0
##   Middle East and North Africa                          1
##   South Asia                                            1
##   Sub-Saharan Africa                                   20
##   United States                                         0
##   Western Europe and Anglosphere                        0
kruskal.test(hours_worker ~ cluster, data = df)$p.value
## [1] 5.761585e-12
kruskal.test(hours_adult ~ cluster, data = df)$p.value
## [1] 4.028138e-15
df %>% pivot_longer(c(hours_worker, hours_adult), names_to = "measure", values_to = "hours") %>%
  ggplot(aes(cluster, hours)) + geom_boxplot() + facet_wrap(~ measure, scales = "free_y") +
  labs(x = NULL, y = "weekly hours") + theme(axis.text.x = element_text(angle = 30, hjust = 1))

The five groups can be summarised by their distinctive characteristics:

  • Redistributive: Countries in this group, including much of Europe and the Anglosphere, combine substantial redistribution (roughly one third of market-income inequality) with high formal employment and transfers. Average weekly hours are around 35.
  • Low-redistribution, high-employment: This group includes parts of East and Southeast Asia and Latin America. Relatively high employment and limited redistribution coincide with long hours per worker and high hours per adult.
  • High market inequality: Countries in this group, including parts of Latin America and Southern Africa, have the highest average market Gini (around 52), limited redistribution and comparatively low employment.
  • Male-breadwinner: This group is concentrated in the Middle East, North Africa and South Asia. The employment gap between men and women is around 40 percentage points, and hours among those employed are the longest.
  • Informal full-employment: Many Sub-Saharan African countries fall in this group. Employment is high, formal employment is around 10%, and hours per adult are the highest despite moderate hours per worker. The label is descriptive, not a claim of zero unemployment.

The Kruskal–Wallis comparisons indicate differences in both working-time measures (p < 0.001). These are descriptive comparisons because working hours were excluded from the clustering inputs. The male-breadwinner group combines long hours among workers with low employment, whereas the informal high-employment group has high aggregate labour input. The distinction between intensive and extensive margins is therefore essential.

Is it more than rich versus poor?

rs_gdp <- rotated_scores(scale(cbind(X, log_gdp = df$log_gdp)), n_pc)
km_gdp <- kmeans(rs_gdp$scores, k, nstart = 100)
ari(km$cluster, km_gdp$cluster)
## [1] 0.7737906
summary(lm(log_gdp ~ cluster, data = df))$r.squared
## [1] 0.5709581
specs <- list(gdp_linear = hours_worker ~ log_gdp,
              gdp_cubic  = hours_worker ~ poly(log_gdp, 3, raw = TRUE),
              regimes    = hours_worker ~ cluster,
              regimes_gdp = hours_worker ~ cluster + poly(log_gdp, 3, raw = TRUE))

# Everything is rebuilt inside every training fold: imputation (mice with the test rows ignored when the
# imputation models are fitted), standardisation with training means and SDs, PCA, rotation and k-means.
# Test countries are projected with the training PCA and assigned to the nearest training centroid,
# so the test data never shape the regimes.
fold_regimes <- function(tr) {
  Xf <- complete(mice(df[features], m = 1, method = "pmm", ignore = !tr, printFlag = FALSE, seed = 1))
  mu <- colMeans(Xf[tr, ]); sdv <- apply(Xf[tr, ], 2, sd)
  Zf <- scale(Xf, center = mu, scale = sdv)
  p  <- prcomp(Zf[tr, ])
  r  <- varimax(p$rotation[, 1:n_pc] %*% diag(p$sdev[1:n_pc]))
  sc <- function(Z) sweep(predict(p, Z)[, 1:n_pc, drop = FALSE], 2, p$sdev[1:n_pc], "/") %*% r$rotmat
  km_tr <- kmeans(sc(Zf[tr, ]), k, nstart = 50)
  te <- sc(Zf[!tr, , drop = FALSE])
  cl <- integer(nrow(Zf)); cl[tr] <- km_tr$cluster
  cl[!tr] <- apply(te, 1, function(x) which.min(colSums((t(km_tr$centers) - x)^2)))
  factor(cl)
}
cv_compare <- function(reps = 20) {
  out <- replicate(reps, {
    fo <- sample(rep(1:10, length.out = nrow(df)))
    err <- matrix(NA, nrow(df), length(specs), dimnames = list(NULL, names(specs)))
    for (f in 1:10) {
      tr <- fo != f
      d <- df; d$cluster <- fold_regimes(tr)
      for (m in names(specs)) err[!tr, m] <- predict(lm(specs[[m]], data = d[tr, ]), d[!tr, ]) - d$hours_worker[!tr]
    }
    sqrt(colMeans(err^2))
  })
  rowMeans(out)
}
set.seed(1)
gdp_tab <- data.frame(model = names(specs),
  adj_R2 = sapply(specs, function(fm) summary(lm(fm, data = df))$adj.r.squared),
  cv_RMSE = cv_compare())
gdp_tab[, 2:3] <- round(gdp_tab[, 2:3], 3); gdp_tab
##                   model adj_R2 cv_RMSE
## gdp_linear   gdp_linear  0.074   5.628
## gdp_cubic     gdp_cubic  0.182   5.369
## regimes         regimes  0.345   4.736
## regimes_gdp regimes_gdp  0.351   4.787

The regimes are related to GDP: cluster membership explains about 0.57 of the variance of log GDP, and adding GDP to the clustering changes the partition only moderately (ARI about 0.77). But for working time the regimes carry more information than income. To make the comparison fair, the table uses the adjusted R² (which penalises the extra parameters of the five-category variable) and the 10-fold cross-validated prediction error (with imputation, standardisation, PCA and clustering all repeated inside each training fold), and it allows GDP to enter non-linearly (a cubic polynomial). The regimes have an adjusted R² of about 0.34 against 0.18 for the flexible GDP model, and a lower out-of-sample error (4.74 vs 5.37 hours). The typology is therefore not just rich versus poor, although these are associations, not causal effects.

How certain is each country’s assignment? Consensus clustering

B <- 200; n <- nrow(scores)
together <- matrix(0, n, n); sampled <- matrix(0, n, n)
for (b in 1:B) {
  i <- sample(n, round(0.8 * n))
  cl <- kmeans(scores[i, ], k, nstart = 20)$cluster
  sampled[i, i] <- sampled[i, i] + 1
  together[i, i] <- together[i, i] + outer(cl, cl, "==")
}
cons <- together / pmax(sampled, 1)
certainty <- sapply(1:n, function(i) mean(cons[i, km$cluster == km$cluster[i]]))
names(certainty) <- df$country
round(tapply(certainty, cl_name, mean), 2)
##                      Redistributive Low-redistribution, high-employment 
##                                0.97                                0.86 
##              High market inequality                    Male-breadwinner 
##                                0.83                                0.96 
##            Informal full-employment 
##                                0.95
sort(round(certainty, 2))[1:12]
##      Suriname         Chile    Kazakhstan Cote d'Ivoire       Grenada 
##          0.30          0.44          0.44          0.48          0.55 
##    Costa Rica        Guyana        Serbia      Honduras      Cambodia 
##          0.56          0.58          0.59          0.61          0.61 
##         Nepal       Armenia 
##          0.65          0.75
jac <- sapply(levels(cl_name), function(g) {
  a <- which(cl_name == g)
  mean(replicate(100, { i <- sample(n, round(0.8 * n)); cl <- kmeans(scores[i, ], k, nstart = 20)$cluster
    ai <- intersect(a, i); max(sapply(unique(cl), function(c) { b <- i[cl == c]; length(intersect(ai, b)) / length(union(ai, b)) })) }))
})
round(jac, 2)
##                      Redistributive Low-redistribution, high-employment 
##                                0.97                                0.91 
##              High market inequality                    Male-breadwinner 
##                                0.86                                0.89 
##            Informal full-employment 
##                                0.91
ord <- order(cl_name, -certainty)
image(cons[ord, ord], col = gray.colors(20, start = 1, end = 0), axes = FALSE,
      main = "Co-assignment probabilities (countries ordered by cluster)")

For each pair of countries the matrix shows how often they end up in the same cluster across 200 subsamples. Clear dark blocks on the diagonal mean stable regimes. The average certainty is high for the redistributive, male-breadwinner and informal full-employment regimes, and lower for the other two, whose border is fuzzy. The least certain countries (for example Suriname, Kazakhstan and Chile) are the ones whose regime label should not be taken literally. Following Kopczewska and Ćwiakowski (2021), who track the stability of housing submarkets with the Rand index and Jaccard similarity, I also report for each regime the average Jaccard similarity between the regime and its best match in the subsamples. Following Hennig (2007), values above about 0.75 are read as a stable cluster, values below 0.5 as a cluster that dissolves when the sample changes.

Life-cycle profiles across the typology

df %>% group_by(cluster) %>% summarise(fpc1 = round(mean(fpc1), 1), fpc2 = round(mean(fpc2), 1)) %>% as.data.frame()
##                               cluster   fpc1  fpc2
## 1                      Redistributive   23.6 -35.6
## 2 Low-redistribution, high-employment    4.5   4.8
## 3              High market inequality  -35.0   7.5
## 4                    Male-breadwinner -100.5  23.6
## 5            Informal full-employment   80.1  31.1
kruskal.test(fpc1 ~ cluster, data = df)$p.value
## [1] 1.983719e-21
kruskal.test(fpc2 ~ cluster, data = df)$p.value
## [1] 1.950794e-17

The life-cycle components, which were not used for clustering, also differ strongly between regimes. The informal full-employment regime has high female participation at all ages and much work among the young and the old. The male-breadwinner regime has the lowest female participation. The redistributive regime has the latest entry and earliest exit from work, which is consistent with long education and pension systems. The regimes are thus visible not only in averages but also in the shape of working life.

Countries in between: fuzzy clustering

Fuzzy clustering (fanny; Kaufman and Rousseeuw 1990) gives each country a degree of membership in every regime instead of a single label.

fz <- lapply(c(1.2, 1.5, 2), function(m) fanny(scores, k = k, memb.exp = m))
## Warning in fanny(scores, k = k, memb.exp = m): przynależności są bardzo bliskie
## 1/k. Może zmniejszyć 'memb.exp'?
data.frame(memb_exp = c(1.2, 1.5, 2),
           dunn_coef = sapply(fz, function(f) round(f$coeff[1], 2)),
           ARI_with_kmeans = sapply(fz, function(f) round(ari(km$cluster, f$clustering), 2)),
           share_without_dominant = sapply(fz, function(f) round(mean(apply(f$membership, 1, max) < 0.6), 2)))
##   memb_exp dunn_coef ARI_with_kmeans share_without_dominant
## 1      1.2      0.88            0.95                   0.06
## 2      1.5      0.50            0.87                   0.38
## 3      2.0      0.20            0.27                   1.00
memb <- round(fz[[2]]$membership, 2); rownames(memb) <- df$country
colnames(memb) <- levels(cl_name)[apply(table(cl_name, fz[[2]]$clustering), 2, which.max)]
memb[apply(memb, 1, max) < 0.5, ]
##                          Low-redistribution, high-employment Male-breadwinner
## Albania                                                 0.09             0.08
## Armenia                                                 0.13             0.23
## Brunei Darussalam                                       0.33             0.10
## Belarus                                                 0.30             0.14
## Central African Republic                                0.08             0.07
## Cote d'Ivoire                                           0.09             0.09
## Chile                                                   0.22             0.16
## Costa Rica                                              0.18             0.37
## Ethiopia                                                0.43             0.08
## Grenada                                                 0.08             0.07
## Guyana                                                  0.09             0.39
## Honduras                                                0.10             0.41
## Iceland                                                 0.26             0.09
## Kyrgyzstan                                              0.39             0.28
## Cambodia                                                0.36             0.07
## Kosovo                                                  0.10             0.30
## Kazakhstan                                              0.39             0.14
## Liberia                                                 0.42             0.07
## Lithuania                                               0.09             0.07
## Moldova                                                 0.15             0.06
## Macedonia                                               0.08             0.14
## Maldives                                                0.29             0.15
## Namibia                                                 0.10             0.14
## Nepal                                                   0.30             0.07
## Peru                                                    0.36             0.06
## Pakistan                                                0.25             0.49
## Romania                                                 0.16             0.17
## Serbia                                                  0.08             0.09
## Suriname                                                0.21             0.30
## Sao Tome and Principe                                   0.34             0.34
## Chad                                                    0.16             0.13
## Uruguay                                                 0.16             0.09
## Uzbekistan                                              0.20             0.36
## Vanuatu                                                 0.29             0.09
## South Africa                                            0.11             0.17
##                          Redistributive High market inequality
## Albania                            0.38                   0.37
## Armenia                            0.13                   0.46
## Brunei Darussalam                  0.42                   0.09
## Belarus                            0.30                   0.12
## Central African Republic           0.08                   0.30
## Cote d'Ivoire                      0.08                   0.38
## Chile                              0.16                   0.38
## Costa Rica                         0.09                   0.31
## Ethiopia                           0.08                   0.09
## Grenada                            0.06                   0.44
## Guyana                             0.05                   0.43
## Honduras                           0.04                   0.40
## Iceland                            0.41                   0.10
## Kyrgyzstan                         0.09                   0.19
## Cambodia                           0.06                   0.09
## Kosovo                             0.16                   0.35
## Kazakhstan                         0.30                   0.10
## Liberia                            0.06                   0.08
## Lithuania                          0.43                   0.30
## Moldova                            0.43                   0.14
## Macedonia                          0.26                   0.45
## Maldives                           0.06                   0.35
## Namibia                            0.13                   0.43
## Nepal                              0.10                   0.10
## Peru                               0.05                   0.11
## Pakistan                           0.07                   0.12
## Romania                            0.44                   0.18
## Serbia                             0.33                   0.43
## Suriname                           0.09                   0.34
## Sao Tome and Principe              0.04                   0.20
## Chad                               0.05                   0.40
## Uruguay                            0.42                   0.24
## Uzbekistan                         0.22                   0.16
## Vanuatu                            0.09                   0.26
## South Africa                       0.16                   0.41
##                          Informal full-employment
## Albania                                      0.09
## Armenia                                      0.06
## Brunei Darussalam                            0.07
## Belarus                                      0.13
## Central African Republic                     0.46
## Cote d'Ivoire                                0.37
## Chile                                        0.08
## Costa Rica                                   0.05
## Ethiopia                                     0.31
## Grenada                                      0.36
## Guyana                                       0.04
## Honduras                                     0.06
## Iceland                                      0.13
## Kyrgyzstan                                   0.06
## Cambodia                                     0.43
## Kosovo                                       0.08
## Kazakhstan                                   0.07
## Liberia                                      0.38
## Lithuania                                    0.11
## Moldova                                      0.22
## Macedonia                                    0.07
## Maldives                                     0.15
## Namibia                                      0.19
## Nepal                                        0.43
## Peru                                         0.41
## Pakistan                                     0.07
## Romania                                      0.05
## Serbia                                       0.07
## Suriname                                     0.06
## Sao Tome and Principe                        0.07
## Chad                                         0.26
## Uruguay                                      0.09
## Uzbekistan                                   0.07
## Vanuatu                                      0.27
## South Africa                                 0.15

The result depends strongly on the fuzziness parameter. With 1.2 almost every country has a dominant cluster. With 2 the memberships are nearly uniform and the method stops being useful. The value 1.5 is a reasonable middle: it agrees well with k-means, and about a third of the countries have no membership above 0.6. The table lists the clearest in-between cases. Several Balkan and post-Soviet countries lie between the redistributive regime and the others, and several Latin American countries lie between two of the middle regimes. Together with the consensus results, this suggests a structure with a few clear cores and a broad belt of hybrid countries.

DBSCAN: outliers and sensitivity to eps

DBSCAN (Ester et al. 1996) groups points in dense regions and labels isolated points as noise.

kNNdistplot(scores, k = 4)

eps_grid <- c(0.6, 0.8, 1.0, 1.2)
data.frame(eps = eps_grid, t(sapply(eps_grid, function(e) {
  cl <- dbscan(scores, eps = e, minPts = 4)$cluster
  c(clusters = max(cl), noise = sum(cl == 0))
})))
##   eps clusters noise
## 1 0.6        3    28
## 2 0.8        1     7
## 3 1.0        1     5
## 4 1.2        1     5
db <- dbscan(scores, eps = 1.0, minPts = 4)
sort(df$country[db$cluster == 0])
## [1] "Belarus"      "Kosovo"       "Namibia"      "South Africa" "Uzbekistan"

DBSCAN does not find separate dense regions: for most values of eps it finds one cluster and some noise, and only small eps splits the data into several fragments. This agrees with the moderate silhouette. Its useful output is the list of countries that are far from all others at eps = 1: South Africa and Namibia (extreme market inequality), and Belarus, Kosovo and Uzbekistan (unusual combinations of the employment and welfare variables).

Part 3: Association rules

Association rules (Agrawal, Imieliński and Swami 1993) are mined with Apriori. Each country becomes a basket of items: its tercile (low, mid, high) on each feature and on hours per worker. Region is left out of the baskets, because rules that only recognise geography say little. Only rules with hours on the right-hand side are kept.

discretise <- function(x, probs) {
  b <- unique(quantile(x, probs))
  cut(x, b, labels = paste0("q", seq_len(length(b) - 1)), include.lowest = TRUE)
}
basket <- function(probs) {
  b <- X %>% mutate(across(everything(), ~ discretise(.x, probs)))
  b$hours <- discretise(df$hours_worker, probs)
  b
}
disc3 <- basket(c(0, 1/3, 2/3, 1))
trans3 <- as(disc3, "transactions")
itemFrequencyPlot(trans3, topN = 24, cex.names = 0.6)

mine <- function(trans, top, bottom) {
  r <- apriori(trans, parameter = list(supp = 0.06, conf = 0.6, minlen = 2, maxlen = 4),
               appearance = list(rhs = c(top, bottom), default = "lhs"), control = list(verbose = FALSE))
  if (length(r) == 0) { message("No rules found for these thresholds."); return(r) }
  r <- r[!is.redundant(r)]
  r[is.significant(r, trans, method = "fisher", alpha = 0.05, adjust = "bonferroni")]
}
rules3 <- mine(trans3, "hours=q3", "hours=q1")
length(rules3)
## [1] 51
inspect(head(sort(subset(rules3, rhs %in% "hours=q3"), by = "lift"), 8))
##     lhs                     rhs           support confidence   coverage     lift count
## [1] {gender_gap=q3,                                                                   
##      redistribution=q2,                                                               
##      formal=q1}          => {hours=q3} 0.06410256  0.9090909 0.07051282 2.727273    10
## [2] {employment=q1,                                                                   
##      gender_gap=q3,                                                                   
##      redistribution=q2}  => {hours=q3} 0.08333333  0.8666667 0.09615385 2.600000    13
## [3] {employment=q1,                                                                   
##      formal=q1}          => {hours=q3} 0.07051282  0.8461538 0.08333333 2.538462    11
## [4] {gender_gap=q3,                                                                   
##      formal=q1}          => {hours=q3} 0.10256410  0.8000000 0.12820513 2.400000    16
## [5] {employment=q1,                                                                   
##      redistribution=q2}  => {hours=q3} 0.10256410  0.7619048 0.13461538 2.285714    16
## [6] {gender_gap=q3,                                                                   
##      regulations=q3}     => {hours=q3} 0.07692308  0.7500000 0.10256410 2.250000    12
## [7] {gender_gap=q3,                                                                   
##      redistribution=q2}  => {hours=q3} 0.12820513  0.7407407 0.17307692 2.222222    20
## [8] {gender_gap=q3,                                                                   
##      transfers=q1}       => {hours=q3} 0.10256410  0.7272727 0.14102564 2.181818    16
inspect(head(sort(subset(rules3, rhs %in% "hours=q1"), by = "lift"), 8))
##     lhs                     rhs           support confidence   coverage     lift count
## [1] {employment=q3,                                                                   
##      redistribution=q3}  => {hours=q1} 0.06410256  1.0000000 0.06410256 3.000000    10
## [2] {gender_gap=q1,                                                                   
##      regulations=q3,                                                                  
##      formal=q3}          => {hours=q1} 0.08333333  0.9285714 0.08974359 2.785714    13
## [3] {gender_gap=q1,                                                                   
##      redistribution=q3,                                                               
##      regulations=q3}     => {hours=q1} 0.08333333  0.9285714 0.08974359 2.785714    13
## [4] {gender_gap=q1,                                                                   
##      transfers=q3,                                                                    
##      regulations=q3}     => {hours=q1} 0.08333333  0.9285714 0.08974359 2.785714    13
## [5] {gini_market=q3,                                                                  
##      regulations=q3,                                                                  
##      formal=q3}          => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10
## [6] {employment=q2,                                                                   
##      regulations=q3,                                                                  
##      formal=q3}          => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10
## [7] {employment=q2,                                                                   
##      gender_gap=q1,                                                                   
##      regulations=q3}     => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10
## [8] {gini_market=q3,                                                                  
##      transfers=q3,                                                                    
##      regulations=q3}     => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10
plot(head(sort(rules3, by = "lift"), 20), method = "graph")

disc4  <- basket(c(0, 0.25, 0.5, 0.75, 1))
trans4 <- as(disc4, "transactions")
rules4 <- mine(trans4, "hours=q4", "hours=q1")
length(rules4)
## [1] 21
inspect(head(sort(subset(rules4, rhs %in% "hours=q4"), by = "lift"), 5))
##     lhs                                   rhs        support    confidence
## [1] {gender_gap=q4, transfers=q1}      => {hours=q4} 0.07051282 0.8461538 
## [2] {gender_gap=q4, gini_market=q1}    => {hours=q4} 0.07051282 0.7333333 
## [3] {gender_gap=q4, redistribution=q3} => {hours=q4} 0.06410256 0.6666667 
##     coverage   lift     count
## [1] 0.08333333 3.384615 11   
## [2] 0.09615385 2.933333 11   
## [3] 0.09615385 2.666667 10
inspect(head(sort(subset(rules4, rhs %in% "hours=q1"), by = "lift"), 5))
##     lhs                     rhs           support confidence   coverage     lift count
## [1] {redistribution=q4,                                                               
##      regulations=q4}     => {hours=q1} 0.07051282  1.0000000 0.07051282 4.000000    11
## [2] {transfers=q4,                                                                    
##      regulations=q4}     => {hours=q1} 0.07051282  1.0000000 0.07051282 4.000000    11
## [3] {gender_gap=q1,                                                                   
##      redistribution=q4,                                                               
##      formal=q4}          => {hours=q1} 0.07692308  0.9230769 0.08333333 3.692308    12
## [4] {gender_gap=q1,                                                                   
##      redistribution=q4}  => {hours=q1} 0.08974359  0.8750000 0.10256410 3.500000    14
## [5] {gender_gap=q1,                                                                   
##      formal=q4}          => {hours=q1} 0.07692308  0.8571429 0.08974359 3.428571    12

After removing redundant rules and keeping only those that pass Fisher’s exact test with a Bonferroni correction, 51 rules remain with tercile coding and 21 with quartile coding.

Long hours appear together with a large gender gap and informal employment, and with low employment. Short hours appear together with a small gender gap, strong working-time regulations and high redistribution or transfers. Interestingly, regulations, which play a minor role in PCA, appear in many of the rules for short hours: they matter in combination with the other features rather than on their own. The same pattern appears with quartiles, so it does not depend on the cut-off points.

share_lhs <- function(r, pat) if (length(r) == 0) NA else mean(grepl(pat, labels(lhs(r))))
h2 <- tryCatch({
  long3 <- subset(rules3, rhs %in% "hours=q3"); long4 <- subset(rules4, rhs %in% "hours=q4")
  c(rules_long_terciles = length(long3),
    share_gap_informal_lowemp = share_lhs(long3, "gender_gap=q3|formal=q1|employment=q1"),
    share_market_gini = share_lhs(long3, "gini_market"),
    share_high_market_gini = share_lhs(long3, "gini_market=q3"),
    share_high_market_gini_quartiles = share_lhs(long4, "gini_market=q4"))
}, error = function(e) rep(NA_real_, 5))
round(h2, 2)
##              rules_long_terciles        share_gap_informal_lowemp 
##                            12.00                             0.83 
##                share_market_gini           share_high_market_gini 
##                             0.08                             0.00 
## share_high_market_gini_quartiles 
##                             0.00
h2_ok <- isTRUE(h2[2] > 0.5 && h2[3] < 0.25)

Of the 12 tercile rules for long hours, 83% contain a large gender gap, low formal employment or low employment, while 8% contain market inequality at all and 0% contain high market inequality (with quartiles: 0%). This supports H2: long hours go with how work is organised and shared, not with how unequal market incomes are.

Beyond the classes: predicting hours from institutions with CBA

CBA (Liu, Hsu and Ma 1998) builds a classifier from association rules. Here it predicts the hours tercile from the seven features, which were not built from hours, and is evaluated with 5-fold cross-validation. The tercile cut-offs are computed on the training folds only and then applied to the test fold, so that the test data do not influence the discretisation.

cba_data <- disc3
cba_full <- CBA(hours ~ ., data = cba_data, supp = 0.05, conf = 0.6)
inspect(cba_full$rules)
##      lhs                     rhs           support confidence   coverage     lift count size coveredTransactions totalErrors
## [1]  {employment=q3,                                                                                                        
##       redistribution=q3}  => {hours=q1} 0.06410256  1.0000000 0.06410256 3.000000    10    3                  10          94
## [2]  {employment=q1,                                                                                                        
##       redistribution=q2,                                                                                                    
##       formal=q1}          => {hours=q3} 0.05769231  1.0000000 0.05769231 3.000000     9    4                   9          85
## [3]  {employment=q1,                                                                                                        
##       redistribution=q2,                                                                                                    
##       transfers=q2}       => {hours=q3} 0.05769231  1.0000000 0.05769231 3.000000     9    4                   3          82
## [4]  {gender_gap=q1,                                                                                                        
##       gini_market=q3,                                                                                                       
##       regulations=q3,                                                                                                       
##       formal=q3}          => {hours=q1} 0.05769231  1.0000000 0.05769231 3.000000     9    5                   8          74
## [5]  {gender_gap=q1,                                                                                                        
##       regulations=q3,                                                                                                       
##       formal=q3}          => {hours=q1} 0.08333333  0.9285714 0.08974359 2.785714    13    4                   4          72
## [6]  {gini_market=q3,                                                                                                       
##       regulations=q3,                                                                                                       
##       formal=q3}          => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10    4                   2          72
## [7]  {employment=q2,                                                                                                        
##       regulations=q3,                                                                                                       
##       formal=q3}          => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10    4                   1          71
## [8]  {employment=q2,                                                                                                        
##       gender_gap=q1,                                                                                                        
##       regulations=q3}     => {hours=q1} 0.06410256  0.9090909 0.07051282 2.727273    10    4                   1          70
## [9]  {gender_gap=q3,                                                                                                        
##       redistribution=q2,                                                                                                    
##       formal=q1}          => {hours=q3} 0.06410256  0.9090909 0.07051282 2.727273    10    4                   4          68
## [10] {employment=q3,                                                                                                        
##       transfers=q3,                                                                                                         
##       formal=q3}          => {hours=q1} 0.05769231  0.9000000 0.06410256 2.700000     9    4                   1          69
## [11] {gender_gap=q1,                                                                                                        
##       redistribution=q3,                                                                                                    
##       regulations=q2}     => {hours=q1} 0.05769231  0.9000000 0.06410256 2.700000     9    4                   5          66
## [12] {gender_gap=q1,                                                                                                        
##       redistribution=q3}  => {hours=q1} 0.15384615  0.8888889 0.17307692 2.666667    24    3                   1          67
## [13] {gender_gap=q3,                                                                                                        
##       gini_market=q2,                                                                                                       
##       redistribution=q2}  => {hours=q3} 0.05128205  0.8888889 0.05769231 2.666667     8    4                   3          66
## [14] {gender_gap=q3,                                                                                                        
##       transfers=q2,                                                                                                         
##       formal=q1}          => {hours=q3} 0.04487179  0.8750000 0.05128205 2.625000     7    4                   2          66
## [15] {employment=q1,                                                                                                        
##       gender_gap=q3,                                                                                                        
##       redistribution=q2}  => {hours=q3} 0.08333333  0.8666667 0.09615385 2.600000    13    4                   5          65
## [16] {gender_gap=q1,                                                                                                        
##       transfers=q3}       => {hours=q1} 0.14102564  0.8461538 0.16666667 2.538462    22    3                   1          66
## [17] {employment=q1,                                                                                                        
##       formal=q1}          => {hours=q3} 0.07051282  0.8461538 0.08333333 2.538462    11    3                   3          65
## [18] {gender_gap=q1,                                                                                                        
##       gini_market=q3,                                                                                                       
##       regulations=q3}     => {hours=q1} 0.07051282  0.8461538 0.08333333 2.538462    11    4                   4          64
## [19] {gini_market=q2,                                                                                                       
##       redistribution=q3,                                                                                                    
##       transfers=q3}       => {hours=q1} 0.07051282  0.8461538 0.08333333 2.538462    11    4                   4          62
## [20] {regulations=q3,                                                                                                       
##       formal=q3}          => {hours=q1} 0.10256410  0.8421053 0.12179487 2.526316    16    3                   1          62
## [21] {gini_market=q3,                                                                                                       
##       redistribution=q3,                                                                                                    
##       regulations=q3}     => {hours=q1} 0.06410256  0.8333333 0.07692308 2.500000    10    4                   1          63
## [22] {gender_gap=q3,                                                                                                        
##       transfers=q1,                                                                                                         
##       formal=q1}          => {hours=q3} 0.05769231  0.8181818 0.07051282 2.454545     9    4                   4          61
## [23] {gender_gap=q3,                                                                                                        
##       transfers=q1,                                                                                                         
##       regulations=q3}     => {hours=q3} 0.05769231  0.8181818 0.07051282 2.454545     9    4                   3          59
## [24] {gini_market=q2,                                                                                                       
##       redistribution=q2,                                                                                                    
##       transfers=q2}       => {hours=q3} 0.05769231  0.8181818 0.07051282 2.454545     9    4                   5          57
## [25] {}                   => {hours=q2} 0.33333333  0.3333333 1.00000000 1.000000   156    1                  71          57
folds <- sample(rep(1:5, length.out = nrow(cba_data)))
cut_with <- function(x, br) { br <- unique(br); cut(x, br, labels = paste0("q", seq_len(length(br) - 1)), include.lowest = TRUE) }
cv_acc <- sapply(1:5, function(f) {
  tr <- folds != f
  raw_all <- cbind(X, hours = df$hours_worker)
  breaks <- lapply(raw_all[tr, ], function(x) { b <- quantile(x, c(0, 1/3, 2/3, 1)); b[1] <- -Inf; b[4] <- Inf; b })
  d <- as.data.frame(Map(cut_with, raw_all, breaks))
  m <- CBA(hours ~ ., data = d[tr, ], supp = 0.05, conf = 0.6)
  mean(predict(m, d[!tr, ]) == d$hours[!tr])
})
round(c(cv_accuracy = mean(cv_acc), guessing = max(table(cba_data$hours)) / nrow(cba_data)), 2)
## cv_accuracy    guessing 
##        0.51        0.33

Cross-validated accuracy is 0.51, compared with 0.33 for always guessing the most common tercile. The seven features, which contain no information on hours, therefore predict the hours tercile clearly better than chance, but far from perfectly: about half of the countries are still put in the wrong tercile. The rules kept by the full model repeat the pattern found above: high employment with high redistribution, or a small gender gap with strong regulations and formal jobs, predict short hours, while low employment with informal jobs and medium redistribution predicts long hours.

Part 4: Discrete regimes or a continuum?

The earlier results suggest stable group centres but uncertain boundaries. This section examines whether the observed structure is better described by separated clusters or overlapping configurations. Persistent homology and Mapper do not require a fixed number of clusters; simulations compare their interpretation with clustering diagnostics, and spatial analysis evaluates geographical dependence.

Persistent homology

Persistent homology (Edelsbrunner, Letscher and Zomorodian 2002; Carlsson 2009) looks at the data at all scales at once. Each country is a point in the space of the three rotated components. Growing a ball of radius \(\varepsilon\) around every point, clusters appear as connected components (\(H_0\)) that merge as \(\varepsilon\) grows, and loops (\(H_1\)) appear and fill in. A feature that lives over a long range of \(\varepsilon\) is real structure; short-lived features are noise. For \(H_0\) the merge heights are exactly the heights of single-linkage clustering, so they can be computed without special software. As a reference I use data in which each component is permuted independently across countries, which keeps the marginal distributions but destroys any joint structure.

h0 <- function(Z) sort(hclust(dist(Z), method = "single")$height, decreasing = TRUE)
d0 <- h0(scores)
null0 <- replicate(200, h0(apply(scores, 2, sample)))
round(rbind(data = d0[1:8], null_median = apply(null0, 1, median)[1:8],
            null_95 = apply(null0, 1, quantile, 0.95)[1:8]), 2)
##             [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## data        1.38 1.30 1.24 1.23 1.14 0.86 0.80 0.74
## null_median 1.48 1.31 1.15 1.06 1.00 0.95 0.91 0.89
## null_95     1.98 1.66 1.35 1.23 1.16 1.08 1.03 0.99
plot(NULL, xlim = c(0, max(d0)), ylim = c(0, 30), xlab = "scale (epsilon)", ylab = "", yaxt = "n",
     main = "H0 barcode: the 30 longest-lived components")
segments(0, 1:30, d0[1:30], 1:30, lwd = 2)

eps <- seq(0, max(d0), length.out = 200)
betti0 <- function(d) sapply(eps, function(e) sum(d > e) + 1)
plot(eps, betti0(d0), type = "l", lwd = 2, log = "y", xlab = "scale (epsilon)", ylab = "number of components",
     main = "Betti-0 curve")
lines(eps, betti0(apply(null0, 1, median)), lty = 2, col = "red")
legend("topright", c("data", "permuted data (median)"), lty = c(1, 2), col = c(1, 2), bty = "n")

setNames(df$country[cutree(hclust(dist(scores), method = "single"), k = 6) != 1], NULL)
## [1] "Belarus"      "Kosovo"       "Namibia"      "Uzbekistan"   "South Africa"
ph_fun <- if (requireNamespace("ripserr", quietly = TRUE)) {
  function(Z) as.data.frame(ripserr::vietoris_rips(Z, max_dim = 1))
} else if (requireNamespace("TDAstats", quietly = TRUE)) {
  function(Z) as.data.frame(TDAstats::calculate_homology(Z, dim = 1))
} else NULL
h1 <- tryCatch({
  if (is.null(ph_fun)) stop("neither ripserr nor TDAstats is installed")
  pers1 <- function(Z) { x <- ph_fun(Z); x <- x[x$dimension == 1, ]; sort(x$death - x$birth, decreasing = TRUE) }
  p1 <- pers1(scores)
  n1 <- replicate(50, max(c(0, pers1(apply(scores, 2, sample)))))
  list(longest_loops = round(p1[1:5], 2), null_95_longest = round(unname(quantile(n1, 0.95)), 2),
       loops_above_null = sum(p1 > quantile(n1, 0.95)))
}, error = function(e) paste("H1 not computed (install the ripserr package):", conditionMessage(e)))
h1
## $longest_loops
## [1] 0.46 0.33 0.27 0.27 0.22
## 
## $null_95_longest
## [1] 0.62
## 
## $loops_above_null
## [1] 0

To check whether the absence of separated components depends on the particular countries in the sample, the comparison with permuted data is repeated in 50 subsamples of 80% of the countries.

set.seed(4)
sub_tda <- t(replicate(50, { i <- sample(n, round(0.8 * n)); Z <- scores[i, ]
  d <- h0(Z)[1:5]; nul <- replicate(50, h0(apply(Z, 2, sample))[1:5])
  c(above_null95 = sum(d > apply(nul, 1, quantile, 0.95)), ratio_longest = d[1] / median(nul[1, ])) }))
round(c(share_any_bar_above_null = mean(sub_tda[, "above_null95"] > 0),
        mean_bars_above = mean(sub_tda[, "above_null95"]),
        ratio_longest_median = median(sub_tda[, "ratio_longest"])), 2)
## share_any_bar_above_null          mean_bars_above     ratio_longest_median 
##                     0.20                     0.32                     0.97
d0_imp <- sapply(1:5, function(m) h0(rotated_scores(scale(complete(imp, m)), n_pc)$scores))
round(sapply(2:5, function(m) max(abs(d0_imp[, m] - d0_imp[, 1]))), 3)
## [1] 0.203 0.204 0.236 0.111

The \(H_0\) results answer the question of separation directly. None of the long-lived components in the real data lives longer than in the permuted data: the longest bars are about 1.2–1.4, inside the range of the permuted reference. The countries therefore do not fall into groups separated by empty space. The longest bars belong to single isolated countries (South Africa, Namibia, Belarus, Kosovo and Uzbekistan separate first, the same countries DBSCAN flags as noise), not to groups of countries. The diagrams are similar across the five imputations: the largest shift of any merge height, an upper bound on the bottleneck distance between the \(H_0\) diagrams, is about 0.1–0.25, small next to bar lengths above 1. In the subsamples at least one of the five longest bars exceeds the 95th percentile of the permuted data in 20% of cases, about what chance alone would give when five bars are compared, so the result does not depend on a few countries. For \(H_1\), the longest loop in the data lives for about 0.46, against a 95th percentile of 0.62 for the longest loop in permuted data; 0 loops exceed this reference. There is therefore no ring structure either: countries do not move around a circle of configurations.

Persistent homology here is a check, not a classifier: single-linkage merge heights are sensitive to isolated points, and in three dimensions with 156 points small differences between bars should not be over-read.

Mapper

Mapper (Singh, Mémoli and Carlsson 2007) summarises the shape of the data as a graph. Countries are sorted by a filter, here the welfare-state component, into overlapping intervals; within each interval they are grouped by single-linkage clustering, and two groups are joined by an edge when they share countries. Hours were not used to build the graph; each node is coloured by the average hours per worker of its countries.

mapper <- function(Z, f, n_int = 8, overlap = 0.5, h = 1) {
  len <- diff(range(f)) / (n_int - (n_int - 1) * overlap)
  starts <- min(f) + (0:(n_int - 1)) * len * (1 - overlap)
  nodes <- list()
  for (j in seq_along(starts)) {
    idx <- which(f >= starts[j] - 1e-9 & f <= starts[j] + len + 1e-9)
    if (length(idx) == 0) next
    cl <- if (length(idx) == 1) 1 else cutree(hclust(dist(Z[idx, , drop = FALSE]), "single"), h = h)
    for (c in unique(cl)) nodes[[length(nodes) + 1]] <- idx[cl == c]
  }
  pairs <- t(combn(length(nodes), 2))
  edges <- pairs[apply(pairs, 1, function(p) length(intersect(nodes[[p[1]]], nodes[[p[2]]])) > 0), , drop = FALSE]
  list(nodes = nodes, edges = edges)
}
mp <- mapper(scores, scores[, "welfare_state"])
node_x <- sapply(mp$nodes, function(i) mean(scores[i, "welfare_state"]))
node_y <- sapply(mp$nodes, function(i) mean(scores[i, "employment"]))
node_h <- sapply(mp$nodes, function(i) mean(df$hours_worker[i]))
node_reg <- sapply(mp$nodes, function(i) names(which.max(table(cl_name[i]))))
pal <- hcl.colors(20, "YlOrRd", rev = TRUE)
col_h <- pal[cut(node_h, seq(min(df$hours_worker), max(df$hours_worker), length.out = 21), include.lowest = TRUE)]
plot(node_x, node_y, type = "n", xlab = "welfare-state component (filter)", ylab = "employment component",
     main = "Mapper graph, coloured by hours per worker")
segments(node_x[mp$edges[, 1]], node_y[mp$edges[, 1]], node_x[mp$edges[, 2]], node_y[mp$edges[, 2]], col = "grey50")
points(node_x, node_y, pch = 21, bg = col_h, cex = 1 + sqrt(lengths(mp$nodes)) / 2)
text(node_x, node_y, substr(node_reg, 1, 3), cex = 0.6, pos = 3)

comp <- seq_along(mp$nodes)
repeat { old <- comp; for (e in seq_len(nrow(mp$edges))) comp[mp$edges[e, ]] <- min(comp[mp$edges[e, ]]); if (all(old == comp)) break }
main <- as.integer(names(which.max(table(comp))))
c(nodes = length(mp$nodes), edges = nrow(mp$edges), components = length(unique(comp)),
  countries_in_main_component = length(unique(unlist(mp$nodes[comp == main]))))
##                       nodes                       edges 
##                          24                          18 
##                  components countries_in_main_component 
##                           7                         150
sort(unique(df$country[unlist(mp$nodes[comp != main])]))
## [1] "Belarus"      "Brazil"       "Kosovo"       "Namibia"      "South Africa"
## [6] "Uzbekistan"
data.frame(node = seq_along(mp$nodes), n = lengths(mp$nodes), regime = node_reg, hours = round(node_h, 1),
           welfare = round(node_x, 2), employment = round(node_y, 2))
##    node  n                              regime hours welfare employment
## 1     1 55            Informal full-employment  41.5   -0.95       0.38
## 2     2  1              High market inequality  44.3   -0.89      -0.45
## 3     3  1                    Male-breadwinner  46.9   -0.78      -1.68
## 4     4  1                    Male-breadwinner  41.1   -0.75      -2.64
## 5     5 62 Low-redistribution, high-employment  42.9   -0.68      -0.20
## 6     6  1              High market inequality  44.3   -0.89      -0.45
## 7     7 40 Low-redistribution, high-employment  42.0   -0.30      -0.51
## 8     8  1              High market inequality  40.1   -0.22      -0.32
## 9     9  1              High market inequality  42.0   -0.16      -1.32
## 10   10 23 Low-redistribution, high-employment  40.1    0.11      -0.39
## 11   11  1              High market inequality  40.1   -0.22      -0.32
## 12   12  1              High market inequality  42.0   -0.16      -1.32
## 13   13 11                      Redistributive  39.3    0.59      -0.30
## 14   14  6 Low-redistribution, high-employment  42.1    0.52       0.20
## 15   15  1              High market inequality  41.0    0.60      -2.14
## 16   16  1                      Redistributive  23.9    0.74       1.34
## 17   17 25                      Redistributive  37.6    1.02       0.18
## 18   18  1              High market inequality  41.0    0.60      -2.14
## 19   19 26                      Redistributive  35.6    1.37       0.18
## 20   20  1                      Redistributive  30.4    1.56       1.34
## 21   21  1                    Male-breadwinner  44.7    1.42      -1.73
## 22   22 20                      Redistributive  32.4    1.72       0.26
## 23   23  1                      Redistributive  36.1    2.07       1.14
## 24   24  1                    Male-breadwinner  44.7    1.42      -1.73

Under the baseline Mapper settings, 150 of 156 countries belong to one connected component. The remaining nodes are isolated countries, including Brazil and several DBSCAN outliers. Along the welfare-state filter, node-average weekly hours generally decline from approximately 42 to 32. This is consistent with a gradual institutional gradient rather than sharply separated groups.

The graph is sensitive to the cover and linkage choices. The following grid varies interval count, overlap and linkage height, and records connectivity and the association between node position and average hours.

grid <- expand.grid(n_int = c(6, 8, 10), overlap = c(0.3, 0.5), h = c(0.8, 1, 1.2))
sens <- t(apply(grid, 1, function(g) {
  m <- mapper(scores, scores[, "welfare_state"], n_int = g[1], overlap = g[2], h = g[3])
  comp <- seq_along(m$nodes)
  repeat { old <- comp; for (e in seq_len(nrow(m$edges))) comp[m$edges[e, ]] <- min(comp[m$edges[e, ]]); if (all(old == comp)) break }
  mainc <- as.integer(names(which.max(table(comp))))
  nx <- sapply(m$nodes, function(i) mean(scores[i, "welfare_state"])); nh <- sapply(m$nodes, function(i) mean(df$hours_worker[i]))
  c(nodes = length(m$nodes), components = length(unique(comp)),
    share_in_main = length(unique(unlist(m$nodes[comp == mainc]))) / n,
    rank_cor_filter_hours = cor(nx, nh, method = "spearman"))
}))
sens <- cbind(grid, round(sens, 2)); sens
##    n_int overlap   h nodes components share_in_main rank_cor_filter_hours
## 1      6     0.3 0.8    24          9          0.67                 -0.66
## 2      8     0.3 0.8    24         10          0.94                 -0.74
## 3     10     0.3 0.8    31         11          0.94                 -0.53
## 4      6     0.5 0.8    20          8          0.96                 -0.63
## 5      8     0.5 0.8    30          9          0.95                 -0.64
## 6     10     0.5 0.8    30          9          0.95                 -0.69
## 7      6     0.3 1.0    18          7          0.68                 -0.49
## 8      8     0.3 1.0    19          7          0.96                 -0.62
## 9     10     0.3 1.0    23          8          0.96                 -0.46
## 10     6     0.5 1.0    17          6          0.97                 -0.50
## 11     8     0.5 1.0    24          7          0.96                 -0.52
## 12    10     0.5 1.0    24          6          0.97                 -0.49
## 13     6     0.3 1.2    14          6          0.97                 -0.36
## 14     8     0.3 1.2    15          6          0.97                 -0.55
## 15    10     0.3 1.2    17          6          0.97                 -0.45
## 16     6     0.5 1.2    14          5          0.97                 -0.38
## 17     8     0.5 1.2    19          6          0.97                 -0.42
## 18    10     0.5 1.2    21          6          0.97                 -0.47
round(c(min_share_in_main = min(sens$share_in_main), max_rank_cor = max(sens$rank_cor_filter_hours)), 2)
## min_share_in_main      max_rank_cor 
##              0.67             -0.36

Across the 18 settings the largest component always contains at least 67% of the countries, and the rank correlation between the welfare-state filter and hours is negative in 18 of them. The picture of one connected band along which hours fall does not depend on the particular settings.

Monte Carlo: what do the methods find when the truth is known?

The real data cannot tell which structure produced them, but simulations can show how the methods used in this paper behave under each candidate structure. I simulate 156 points in three dimensions under six scenarios, each standardised like the real component scores:

  • A. Separated clusters: five Gaussian clusters at the real k-means centres, pulled twice as far apart, with small spread.
  • B. Overlapping clusters: five Gaussian clusters at the real centres with the real within-cluster spread.
  • C. Continuum: one multivariate normal distribution, no clusters at all.
  • D. Branching continuum: points along three branches that meet in a common centre, with noise, so that there are “types” at the ends of the branches and hybrids in between, but no gaps.
  • E. Overlapping clusters with missing data: as B, but 12% of the values are deleted at random and imputed with predictive mean matching, as in the real data.
  • F. Overlapping clusters with spatial dependence and missing data: each real country keeps its regime and its location, but its position around the regime centre is drawn with spatially autocorrelated noise (a spatial autoregressive process on the five-nearest-neighbour weights with parameter 0.4, close to the spatial lag estimated below), so neighbouring countries deviate from their regime in similar directions; then 12% of the values are deleted and imputed as in E.

For each of 200 data sets per scenario I record, for k-means, PAM and Ward clustering, the number of clusters preferred by the silhouette (k = 2 to 6) and, where the true clusters are known (A, B, E, F), the agreement of the five-cluster solution with them (ARI). I also record the best k-means silhouette, the bootstrap stability of k-means at k = 5, the number of DBSCAN clusters and the share of noise at eps = 1, and the longest \(H_0\) bar relative to column-permuted data.

# warnings switched off here only: 1,200 simulated data sets can produce many repeated k-means convergence notes
within_sd <- sqrt(mean(sapply(1:k, function(j) apply(scores[km$cluster == j, , drop = FALSE], 2, var))))
geo_mc <- read.csv("country_coords.csv")[match(df$iso3, read.csv("country_coords.csv")$iso3), ]
la <- geo_mc$lat * pi / 180; lo <- geo_mc$lon * pi / 180
D_mc <- 2 * 6371 * asin(pmin(sqrt(sin(outer(la, la, "-") / 2)^2 + outer(cos(la), cos(la)) * sin(outer(lo, lo, "-") / 2)^2), 1))
W_mc <- t(apply(D_mc, 1, function(r) { w <- numeric(length(r)); w[order(r)[2:6]] <- 1 / 5; w }))
SAR_mc <- solve(diag(n) - 0.4 * W_mc)
sim <- function(type) {
  sz <- as.vector(table(km$cluster)); C <- km$centers; truth <- rep(1:k, sz)
  gauss <- function(sd, mult) do.call(rbind, lapply(1:k, function(j)
    sweep(matrix(rnorm(sz[j] * 3, sd = sd), ncol = 3), 2, mult * C[j, ], "+")))
  Z <- switch(type,
    A = gauss(0.5 * within_sd, 2),
    B = gauss(within_sd, 1),
    C = { truth <- NA; matrix(rnorm(n * 3), ncol = 3) },
    D = { truth <- NA; dirs <- rbind(c(1, 0, 0), c(-0.5, 0.87, 0), c(-0.5, -0.87, 0.5)); b <- sample(1:3, n, TRUE)
          tt <- runif(n); t(sapply(1:n, function(i) tt[i] * 2.5 * dirs[b[i], ])) + matrix(rnorm(n * 3, sd = 0.35), ncol = 3) },
    E = { Z <- gauss(within_sd, 1); Z[matrix(runif(length(Z)) < 0.12, nrow(Z))] <- NA
          as.matrix(complete(mice(as.data.frame(Z), m = 1, method = "pmm", printFlag = FALSE))) },
    F = { truth <- km$cluster; e <- SAR_mc %*% matrix(rnorm(n * 3), ncol = 3)
          Z <- C[truth, ] + sweep(e, 2, apply(e, 2, sd), "/") * within_sd
          Z[matrix(runif(length(Z)) < 0.12, nrow(Z))] <- NA
          as.matrix(complete(mice(as.data.frame(Z), m = 1, method = "pmm", printFlag = FALSE))) })
  list(Z = scale(Z), truth = truth)
}
measure <- function(s) {
  Z <- s$Z; D <- dist(Z); hc <- hclust(D, "ward.D2")
  part <- function(kk) list(km = kmeans(Z, kk, nstart = 10)$cluster, pam = pam(D, kk, cluster.only = TRUE),
                            ward = cutree(hc, kk))
  parts <- lapply(2:6, part)
  sil <- sapply(parts, function(p) sapply(p, function(cl) mean(silhouette(cl, D)[, 3])))
  kbest <- (2:6)[apply(sil, 1, which.max)]
  ari_true <- if (all(is.na(s$truth))) rep(NA, 3) else unname(sapply(parts[[4]], ari, s$truth))
  full <- parts[[4]]$km
  stab <- median(replicate(10, { i <- sample(nrow(Z), round(0.8 * nrow(Z))); ari(kmeans(Z[i, ], 5, nstart = 5)$cluster, full[i]) }))
  db <- dbscan(Z, eps = 1, minPts = 4)$cluster
  c(kbest_km = kbest[1], kbest_pam = kbest[2], kbest_ward = kbest[3],
    ari_km = ari_true[1], ari_pam = ari_true[2], ari_ward = ari_true[3],
    sil_km = max(sil[1, ]), stab_km = stab, dbscan_clusters = max(db), dbscan_noise = mean(db == 0),
    h0_ratio = h0(Z)[1] / median(replicate(20, h0(apply(Z, 2, sample))[1])))
}
set.seed(2)
R <- 200
scen <- c(A = "A separated", B = "B overlapping", C = "C continuum", D = "D branching", E = "E overlapping + missing", F = "F spatial + missing")
mc <- lapply(names(scen), function(s) t(replicate(R, measure(sim(s)))))
names(mc) <- scen
real <- measure(list(Z = scores, truth = NA))
summ <- t(sapply(mc, function(M) c(k5_km = mean(M[, "kbest_km"] == 5), k5_pam = mean(M[, "kbest_pam"] == 5),
  k5_ward = mean(M[, "kbest_ward"] == 5), colMeans(M[, c("ari_km", "ari_pam", "ari_ward", "sil_km", "stab_km",
  "dbscan_clusters", "dbscan_noise", "h0_ratio")]))))
real_row <- c(k5_km = unname(real["kbest_km"] == 5), k5_pam = unname(real["kbest_pam"] == 5),
              k5_ward = unname(real["kbest_ward"] == 5), real[c("ari_km", "ari_pam", "ari_ward", "sil_km",
              "stab_km", "dbscan_clusters", "dbscan_noise", "h0_ratio")])
mc_tab <- round(rbind(summ, real_data = real_row), 2); mc_tab
##                         k5_km k5_pam k5_ward ari_km ari_pam ari_ward sil_km
## A separated              0.99   1.00    1.00   1.00    1.00     1.00   0.84
## B overlapping            0.92   0.90    0.88   0.80    0.77     0.71   0.40
## C continuum              0.14   0.17    0.18     NA      NA       NA   0.26
## D branching              0.00   0.01    0.00     NA      NA       NA   0.41
## E overlapping + missing  0.80   0.70    0.70   0.59    0.55     0.51   0.37
## F spatial + missing      0.79   0.70    0.64   0.59    0.57     0.51   0.37
## real_data                1.00   1.00    0.00     NA      NA       NA   0.37
##                         stab_km dbscan_clusters dbscan_noise h0_ratio
## A separated                1.00            5.00         0.00     1.41
## B overlapping              0.96            1.00         0.01     0.84
## C continuum                0.64            1.04         0.06     1.02
## D branching                0.86            1.00         0.01     0.75
## E overlapping + missing    0.94            1.00         0.02     0.91
## F spatial + missing        0.94            1.01         0.02     0.88
## real_data                  0.91            1.00         0.03     0.83
par(mfrow = c(1, 2))
boxplot(lapply(mc, function(M) M[, "sil_km"]), names = names(scen), main = "best k-means silhouette")
abline(h = real["sil_km"], col = "red", lwd = 2)
boxplot(lapply(mc, function(M) M[, "stab_km"]), names = names(scen), main = "k-means stability at k = 5")
abline(h = real["stab_km"], col = "red", lwd = 2)

par(mfrow = c(1, 1))
# distance of the real data from each scenario on the two summary measures, in units of the scenario's SD
round(sapply(mc, function(M) sqrt(((unname(real["sil_km"]) - mean(M[, "sil_km"])) / sd(M[, "sil_km"]))^2 +
                                    ((unname(real["stab_km"]) - mean(M[, "stab_km"])) / sd(M[, "stab_km"]))^2)), 1)
##             A separated           B overlapping             C continuum 
##                    36.3                     2.3                    10.8 
##             D branching E overlapping + missing     F spatial + missing 
##                     1.9                     0.7                     0.7

The simulations separate the extreme scenarios clearly. Well-separated clusters (A) give silhouettes above 0.8, and every method recovers them perfectly. A featureless continuum (C) gives low silhouettes (about 0.26) and low stability (about 0.64), and the silhouette rarely prefers five clusters. The real data (silhouette about 0.37, stability about 0.87) are far from both.

The middle scenarios are harder to tell apart. The last line of output measures how far the real data are from each scenario on the silhouette and the stability together, in units of the scenario’s own spread. The closest scenarios are E overlapping + missing, F spatial + missing, D branching (distances 0.7, 0.7, 1.9). In the branching continuum (D), however, the silhouette almost never prefers five clusters, while in the real data both k-means and PAM do, as they do in most data sets from B, E and F. DBSCAN finds a single cluster in every scenario except A, so it cannot distinguish them. Ward clustering in the real data does not prefer five clusters, which happens in about a third of the data sets from E.

Among the simulated structures, overlapping clusters with noise and missing observations provide a plausible account of the empirical diagnostics. A branching continuum remains a credible alternative. The simulations reject neither all possible continuous distributions nor all possible discrete mixtures: they compare a limited set of candidate mechanisms. Adding the simulated spatial dependence changes little relative to the missing-data scenario.

Spatial structure

Geographical information was excluded from the baseline classification. Spatial dependence in regime membership or regression residuals would therefore indicate additional structure not represented by the institutional partition (Kopczewska 2022, 2027). Capital-city coordinates from GeoNames, stored in country_coords.csv, define great-circle distances. The baseline weights use five nearest capitals, and Moran’s I is evaluated by permutation (Moran 1950).

geo <- read.csv("country_coords.csv")
geo <- geo[match(df$iso3, geo$iso3), ]
gc_dist <- function(lat, lon) {
  la <- lat * pi / 180; lo <- lon * pi / 180
  a <- sin(outer(la, la, "-") / 2)^2 + outer(cos(la), cos(la)) * sin(outer(lo, lo, "-") / 2)^2
  2 * 6371 * asin(pmin(sqrt(a), 1))
}
D_km <- gc_dist(geo$lat, geo$lon)
knn_W <- function(D, kk) { W <- t(apply(D, 1, function(r) { w <- numeric(length(r)); w[order(r)[2:(kk + 1)]] <- 1 / kk; w })); W }
moran <- function(x, W) { z <- x - mean(x); length(x) / sum(W) * sum(W * outer(z, z)) / sum(z^2) }
moran_test <- function(x, W, R = 999) { obs <- moran(x, W); perm <- replicate(R, moran(sample(x), W))
  c(I = obs, expected = -1 / (length(x) - 1), p = (1 + sum(perm >= obs)) / (R + 1)) }
res_regime <- resid(lm(df$hours_worker ~ cl_name))
res_feat   <- resid(lm(df$hours_worker ~ ., data = X))
set.seed(3)
sp <- sapply(c(5, 10), function(kk) { W <- knn_W(D_km, kk)
  rbind(hours_worker = moran_test(df$hours_worker, W), residual_regimes = moran_test(res_regime, W),
        residual_features = moran_test(res_feat, W), redistribution = moran_test(X$redistribution, W)) }, simplify = FALSE)
names(sp) <- c("5 nearest neighbours", "10 nearest neighbours")
lapply(sp, round, 3)
## $`5 nearest neighbours`
##                       I expected     p
## hours_worker      0.444   -0.006 0.001
## residual_regimes  0.175   -0.006 0.001
## residual_features 0.121   -0.006 0.008
## redistribution    0.734   -0.006 0.001
## 
## $`10 nearest neighbours`
##                       I expected     p
## hours_worker      0.370   -0.006 0.001
## residual_regimes  0.115   -0.006 0.002
## residual_features 0.067   -0.006 0.018
## redistribution    0.742   -0.006 0.001
# land borders (GeoNames neighbours) as an alternative weight matrix; island states have no neighbours
nb_list <- strsplit(ifelse(is.na(geo$neighbours), "", geo$neighbours), ";")
Wc <- t(sapply(nb_list, function(v) { w <- as.numeric(df$iso3 %in% v); if (sum(w) > 0) w / sum(w) else w }))
has_nb <- rowSums(Wc) > 0
moran_c <- function(x) { z <- x - mean(x[has_nb]); Wn <- Wc[has_nb, has_nb]; Wn <- Wn / pmax(rowSums(Wn), 1e-12)
  ok <- rowSums(Wn) > 0; zz <- z[has_nb]; sum(ok) / sum(Wn[ok, ]) * sum((Wn * outer(zz, zz))[ok, ]) / sum(zz[ok]^2) }
set.seed(6)
contig <- sapply(list(hours_worker = df$hours_worker, residual_regimes = res_regime), function(x) {
  obs <- moran_c(x); perm <- replicate(999, { y <- x; y[has_nb] <- sample(x[has_nb]); moran_c(y) })
  c(I = obs, p = (1 + sum(perm >= obs)) / 1000) })
c(countries_with_land_neighbours = sum(has_nb)); round(contig, 3)
## countries_with_land_neighbours 
##                            132
##   hours_worker residual_regimes
## I        0.416            0.110
## p        0.001            0.058
W5 <- knn_W(D_km, 5)
same <- function(lab) mean(rowSums(W5 * outer(lab, lab, "==")))
c(share_same_regime = same(cl_name), permutation_mean = mean(replicate(999, same(sample(cl_name)))))
## share_same_regime  permutation_mean 
##         0.5192308         0.2150740
plot(geo$lon, geo$lat, pch = 19, col = as.integer(cl_name) + 1, cex = 0.9, xlab = "longitude", ylab = "latitude",
     main = "Regimes by location of the capital")
legend("bottomleft", levels(cl_name), col = 2:6, pch = 19, cex = 0.6, bty = "n")

Location matters strongly. With five neighbours, Moran’s I is about 0.44 for hours per worker and about 0.73 for redistribution, both far above the value of about zero expected without spatial dependence (permutation p ≈ 0.001). About 52% of each country’s five nearest neighbours share its regime, against about 22% if regimes were spread at random. More interesting is what remains after the regimes. The residuals of hours on the regimes are still positively autocorrelated (I about 0.18), and so, more weakly, are the residuals on the seven features (about 0.12). Neighbouring countries thus work similarly long even after their institutions and distribution are taken into account: part of the variation in working time is regional and is not captured by the features used here. The results are similar with ten neighbours. With weights based on land borders instead of distances (132 countries with at least one land neighbour; Moran’s I for hours 0.42, for the regime residuals 0.11, permutation p = 0.058), the dependence of hours is as strong, while that of the regime residuals is weaker and only borderline significant. Capitals are a crude location for large countries such as Russia or the United States, so the weights are only approximate.

Moran’s I shows that dependence exists, but not what form it takes. Two standard spatial regression models (Anselin 1988) answer this for the regression of hours on the regimes: the spatial lag model, in which a country’s hours depend on its neighbours’ hours, and the spatial error model, in which only the unexplained part is shared with neighbours. Both use the same five-nearest-neighbour weights.

spmod <- tryCatch({
  lw  <- spdep::mat2listw(W5, style = "W")
  dat <- data.frame(hours = df$hours_worker, regime = cl_name)
  ols <- lm(hours ~ regime, data = dat)
  sar <- spatialreg::lagsarlm(hours ~ regime, data = dat, listw = lw)
  sem <- spatialreg::errorsarlm(hours ~ regime, data = dat, listw = lw)
  lr  <- function(m0, m1) pchisq(2 * (as.numeric(logLik(m1)) - as.numeric(logLik(m0))), 1, lower.tail = FALSE)
  list(fit = data.frame(model = c("OLS", "spatial lag (SAR)", "spatial error (SEM)"),
                        AIC = round(c(AIC(ols), AIC(sar), AIC(sem)), 1),
                        spatial_parameter = round(c(NA, sar$rho, sem$lambda), 3),
                        LR_p_vs_OLS = signif(c(NA, lr(ols, sar), lr(ols, sem)), 3)),
       coef = round(cbind(OLS = coef(ols)[-1], SAR = sar$coefficients[-1], SEM = sem$coefficients[-1]), 2))
}, error = function(e) paste("Spatial models not estimated (install spdep and spatialreg):", conditionMessage(e)))
## Warning in spdep::mat2listw(W5, style = "W"): neighbour object has 2 sub-graphs
spmod
## $fit
##                      model   AIC spatial_parameter LR_p_vs_OLS
##                        OLS 933.2                NA          NA
## rho      spatial lag (SAR) 914.2             0.421    4.44e-06
## lambda spatial error (SEM) 922.3             0.441    3.23e-04
## 
## $coef
##                                            OLS  SAR  SEM
## regimeLow-redistribution, high-employment 6.96 4.43 4.94
## regimeHigh market inequality              8.07 5.72 6.08
## regimeMale-breadwinner                    9.28 6.69 6.98
## regimeInformal full-employment            4.32 2.28 2.14
sp_txt <- if (is.list(spmod)) {
  f <- spmod$fit; best <- f$model[which.min(f$AIC)]
  shrink <- 1 - mean(abs(spmod$coef[, "SEM"])) / mean(abs(spmod$coef[, "OLS"]))
  paste0("In the spatial error model the parameter lambda is about ", round(f$spatial_parameter[3], 2),
         " (likelihood-ratio test against OLS p = ", signif(f$LR_p_vs_OLS[3], 2), "), and in the spatial lag model rho is about ",
         round(f$spatial_parameter[2], 2), " (p = ", signif(f$LR_p_vs_OLS[2], 2), "). The model with the lowest AIC is the ",
         best, ". Once spatial dependence is allowed for in the error model, the differences in hours between the regimes ",
         if (shrink >= 0) paste0("shrink on average by about ", round(100 * shrink), "%") else paste0("grow on average by about ", round(-100 * shrink), "%"),
         if (abs(shrink) < 0.25) ", so the regimes keep most of their explanatory power: geography adds to them rather than replacing them."
         else ", so part of what looked like a regime effect is regional clustering of working time.")
} else "The spatial regression models could not be estimated on this machine."

In the spatial error model the parameter lambda is about 0.44 (likelihood-ratio test against OLS p = 0.00032), and in the spatial lag model rho is about 0.42 (p = 4.4e-06). The model with the lowest AIC is the spatial lag (SAR). Once spatial dependence is allowed for in the error model, the differences in hours between the regimes shrink on average by about 30%, so part of what looked like a regime effect is regional clustering of working time.

Finally, location can be put into the clustering itself, in the spirit of the spatial machine learning approaches surveyed by Kopczewska (2022). Each capital is turned into a point on the unit sphere, the three coordinates are standardised and multiplied by a weight \(\alpha\), and k-means is run on the component scores together with these weighted coordinates. With \(\alpha = 0\) the typology is the main one; as \(\alpha\) grows, the clusters become regional blocs.

xyz <- scale(cbind(cos(geo$lat * pi / 180) * cos(geo$lon * pi / 180),
                   cos(geo$lat * pi / 180) * sin(geo$lon * pi / 180), sin(geo$lat * pi / 180)))
set.seed(5)
sp_cl <- t(sapply(c(0, 0.25, 0.5, 0.75, 1), function(a) {
  cl <- kmeans(cbind(scores, a * xyz), k, nstart = 100)$cluster
  c(alpha = a, ARI_with_main = ari(km$cluster, cl), share_same_as_neighbours = same(cl),
    adj_R2_hours = summary(lm(df$hours_worker ~ factor(cl)))$adj.r.squared)
}))
round(sp_cl, 2)
##      alpha ARI_with_main share_same_as_neighbours adj_R2_hours
## [1,]  0.00          1.00                     0.52         0.34
## [2,]  0.25          0.91                     0.53         0.33
## [3,]  0.50          0.87                     0.55         0.34
## [4,]  0.75          0.51                     0.78         0.26
## [5,]  1.00          0.49                     0.83         0.26

Adding location makes the clusters more regional (the share of neighbours in the same cluster rises from 0.52 to 0.83) but moves the partition away from the main typology (ARI 0.49 at alpha = 1). The adjusted R-squared for hours changes from 0.34 to 0.26. Regional blocs do not describe working time better than the institutional typology, so the regimes are not simply geography in disguise.

Robustness

fit_k <- function(Z) kmeans(rotated_scores(scale(Z), n_pc)$scores, k, nstart = 100)$cluster
recent5 <- df$year_gini >= 2018
recent3 <- df$year_gini >= 2020
gap5 <- abs(df$year_gini - df$year_hours) <= 5
gap3 <- abs(df$year_gini - df$year_hours) <= 3
cc <- complete.cases(df[features])
data.frame(
  check = c(paste("imputation", 2:5), "SWIID data from 2018 or later", "SWIID data from 2020 or later",
            "SWIID and hours data at most 5 years apart", "SWIID and hours data at most 3 years apart",
            "complete cases only", "without the formal employment variable",
            "two components (parallel analysis)", "all seven standardised features"),
  n = c(rep(nrow(df), 4), sum(recent5), sum(recent3), sum(gap5), sum(gap3), sum(cc), rep(nrow(df), 3)),
  ARI = round(c(sapply(2:5, function(m) ari(km$cluster, fit_k(complete(imp, m)))),
                ari(km$cluster[recent5], fit_k(X[recent5, ])),
                ari(km$cluster[recent3], fit_k(X[recent3, ])),
                ari(km$cluster[gap5], fit_k(X[gap5, ])),
                ari(km$cluster[gap3], fit_k(X[gap3, ])),
                ari(km$cluster[cc], fit_k(df[cc, features])),
                ari(km$cluster, kmeans(rotated_scores(scale(select(X, -formal)), n_pc)$scores, k, nstart = 100)$cluster),
                ari(km$cluster, kmeans(rotated_scores(Xs, 2)$scores, k, nstart = 100)$cluster),
                ari(km$cluster, kmeans(Xs, k, nstart = 100)$cluster)), 2))
##                                         check   n  ARI
## 1                                imputation 2 156 0.85
## 2                                imputation 3 156 0.86
## 3                                imputation 4 156 0.84
## 4                                imputation 5 156 0.84
## 5               SWIID data from 2018 or later 128 0.77
## 6               SWIID data from 2020 or later 111 0.68
## 7  SWIID and hours data at most 5 years apart 124 0.76
## 8  SWIID and hours data at most 3 years apart 108 0.68
## 9                         complete cases only 137 0.85
## 10     without the formal employment variable 156 0.63
## 11         two components (parallel analysis) 156 0.51
## 12            all seven standardised features 156 0.64

The typology is robust to the imputation (ARI about 0.85) and to dropping imputed countries. It changes more when only countries with recent SWIID data, or with SWIID and hours data at most three to five years apart, are kept, mainly because the smaller sample shifts the borders between the middle regimes. It also changes when the formal employment variable is removed or only two components are kept, which is expected: these choices remove the market inequality or welfare-state dimension. The borders between the middle regimes are the least robust part of the results.

The main analysis uses the first imputation. To see what the choice costs, the whole typology is rebuilt on each of the five imputations and the key quantities are compared. The adjusted R² and the silhouette do not depend on how the clusters are labelled, so they can be compared directly.

pool <- t(sapply(1:5, function(m) {
  Xm <- complete(imp, m); sm <- rotated_scores(scale(Xm), n_pc)$scores
  clm <- kmeans(sm, k, nstart = 100)$cluster
  c(imputation = m, ARI_with_main = ari(km$cluster, clm),
    silhouette = mean(silhouette(clm, dist(sm))[, 3]),
    adj_R2_hours = summary(lm(df$hours_worker ~ factor(clm)))$adj.r.squared)
}))
round(rbind(pool, mean = colMeans(pool)), 3)
##      imputation ARI_with_main silhouette adj_R2_hours
##               1         1.000      0.375        0.345
##               2         0.850      0.378        0.366
##               3         0.860      0.369        0.357
##               4         0.845      0.380        0.364
##               5         0.842      0.384        0.346
## mean          3         0.879      0.377        0.356

Across the five imputations the partitions agree with the main one at an ARI of about 0.84–0.86, the silhouette stays between 0.37 and 0.38, and the regimes explain between 0.35 and 0.37 of the variance of hours per worker (adjusted R²). The first imputation, used in the main analysis, gives the lowest of these R² values, so if anything it understates the link between regimes and working time. None of the conclusions depends on which imputation is used.

The differences in hours between the regimes can also be combined across the five imputations with Rubin’s rules (Rubin 1987). The clusters of each imputation are first matched to the main regimes by their largest overlap; then the regression of hours on the regimes is estimated in each imputation, and the estimates and their variances are pooled.

align <- function(cl, ref) { tab <- table(cl, ref); out <- cl
  for (s in seq_len(nrow(tab))) { ij <- which(tab == max(tab), arr.ind = TRUE)[1, ]
    out[cl == as.integer(rownames(tab)[ij[1]])] <- as.integer(colnames(tab)[ij[2]]); tab[ij[1], ] <- -1; tab[, ij[2]] <- -1 }
  out }
fits <- lapply(1:5, function(m) { sm <- rotated_scores(scale(complete(imp, m)), n_pc)$scores
  reg <- factor(lab[align(kmeans(sm, k, nstart = 100)$cluster, km$cluster)], levels = levels(cl_name))
  lm(df$hours_worker ~ reg) })
Q <- sapply(fits, coef); U <- sapply(fits, function(f) diag(vcov(f))); M <- ncol(Q)
qbar <- rowMeans(Q); ubar <- rowMeans(U); b <- apply(Q, 1, var); tt <- ubar + (1 + 1 / M) * b
nu <- (M - 1) * (1 + ubar / ((1 + 1 / M) * b))^2
rubin <- data.frame(estimate = qbar, se = sqrt(tt), p = 2 * pt(-abs(qbar / sqrt(tt)), nu), fmi = (1 + 1 / M) * b / tt)
rownames(rubin) <- sub("^reg", "", rownames(rubin)); round(rubin, 3)
##                                     estimate    se p   fmi
## (Intercept)                           34.415 0.745 0 0.076
## Low-redistribution, high-employment    6.987 1.070 0 0.084
## High market inequality                 8.336 1.178 0 0.088
## Male-breadwinner                       9.524 1.279 0 0.033
## Informal full-employment               4.770 1.264 0 0.074

The pooled estimates say that employees in the redistributive regime work about 34.4 hours a week, and those in the other regimes between about 4.8 and 9.5 hours more. The fraction of missing information (fmi) is below 9% for every coefficient: the uncertainty caused by the imputation is small compared with the sampling uncertainty.

Stability of the whole procedure

The consensus clustering above resamples countries but keeps the imputed data and the components fixed, so it measures the stability of the clustering step only. Here the whole procedure is repeated on each subsample: imputation, standardisation, PCA with varimax rotation and k-means.

pipe_ari <- replicate(50, {
  i <- sort(sample(nrow(df), round(0.8 * nrow(df))))
  Xi <- complete(mice(df[i, features], m = 1, method = "pmm", printFlag = FALSE))
  ari(km$cluster[i], kmeans(rotated_scores(scale(Xi), n_pc)$scores, k, nstart = 50)$cluster)
})
round(quantile(pipe_ari, c(0.1, 0.5, 0.9)), 2)
##  10%  50%  90% 
## 0.67 0.78 0.86

When the whole procedure is repeated, the partition agrees with the main one with a median ARI of about 0.78 (10th percentile 0.67). This is lower than the stability of the clustering step alone, as it should be, because imputation and PCA now vary too, but it still shows that the main structure does not depend on one particular run of the procedure.

Discussion: selected countries

sel <- c("POL", "USA", "SWE", "DNK", "DEU", "CHN", "ZAF", "IND")
cbind(df %>% filter(iso3 %in% sel) %>%
        select(country, cluster, hours_worker, hours_adult, employment, gender_gap, gini_market, redistribution),
      membership = apply(memb[df$iso3 %in% sel, ], 1, max),
      certainty = round(certainty[df$iso3 %in% sel], 2))
##                   country                             cluster hours_worker
## China               China Low-redistribution, high-employment     43.63250
## Germany           Germany                      Redistributive     30.02714
## Denmark           Denmark                      Redistributive     29.54443
## India               India                    Male-breadwinner     45.81875
## Poland             Poland                      Redistributive     37.49113
## Sweden             Sweden                      Redistributive     29.99121
## USA                   USA                      Redistributive     38.42258
## South Africa South Africa              High market inequality     41.99034
##              hours_adult employment gender_gap gini_market redistribution
## China           29.90951   68.54871  16.540664        47.8      15.271967
## Germany         17.81842   59.34107   9.739697        53.0      42.641509
## Denmark         17.89235   60.56083   7.712144        49.5      41.818182
## India           24.48023   53.42841  39.524210        44.4       8.783784
## Poland          20.74229   55.78245  15.033064        46.5      37.204301
## Sweden          18.61935   62.09560   6.856320        49.3      41.784990
## USA             22.41368   59.37444   9.599820        52.6      25.475285
## South Africa    15.68729   37.35928  10.930016        71.1      12.236287
##              membership certainty
## China              0.68      0.92
## Germany            0.77      0.98
## Denmark            0.80      0.98
## India              0.72      0.98
## Poland             0.89      0.98
## Sweden             0.82      0.98
## USA                0.63      0.98
## South Africa       0.41      0.89

How far is each country from the hours that its features would predict? A simple linear regression of hours per worker on the seven features gives a residual for every country: positive values mean that people work longer than countries with similar institutions and distribution, negative values shorter.

res_fit <- lm(df$hours_worker ~ ., data = X)
res <- setNames(round(resid(res_fit), 1), df$country)
round(summary(res_fit)$adj.r.squared, 2)
## [1] 0.42
head(sort(res, decreasing = TRUE), 8)
##               Bhutan           Azerbaijan              Lesotho 
##                 14.1                 11.4                 10.8 
##             Djibouti         Sierra Leone    Brunei Darussalam 
##                  9.3                  8.8                  8.7 
##                Benin United Arab Emirates 
##                  7.3                  7.1
head(sort(res), 8)
## Kiribati    Tonga  Vanuatu   Rwanda  Moldova  Ecuador Ethiopia    Haiti 
##    -11.6    -10.8    -10.7    -10.2     -9.1     -8.6     -8.5     -8.5
c(residual_Poland = res[["Poland"]], rank_from_top = rank(-res)[["Poland"]], n = length(res))
## residual_Poland   rank_from_top               n 
##             2.5            40.5           156.0
round(cbind(predicted = fitted(res_fit), actual = df$hours_worker, residual = resid(res_fit))[
  match(c("Poland", "Germany", "Sweden", "USA"), df$country), ], 1)
##     predicted actual residual
## 115      35.0   37.5      2.5
## 36       31.7   30.0     -1.7
## 123      32.5   30.0     -2.5
## 146      37.1   38.4      1.3

The seven features explain about two fifths of the variation in hours per worker. The largest positive and negative residuals belong mostly to small countries or to countries with old or uncertain data (for example Brunei, whose SWIID estimate is from 1981), so the extremes of this ranking should not be read literally. For Poland the regression predicts about 35 hours, against about 32 for Germany and 33 for Sweden: roughly 3 of the 7.5 hours separating Poland from them follow from differences in the seven features. The rest is not explained. Poland works about 2.5 hours more than predicted (around the 40th largest residual of 156), while Germany and Sweden work about 2 hours less.

Poland belongs clearly to the redistributive regime, with strong redistribution and a very certain assignment. But Polish employees work about 37.5 hours a week, much more than in Germany, Sweden or Denmark (about 30). In terms of the features used here Poland resembles the Western European countries, but its hours per worker do not; the regime label alone says nothing about the quality of public services or the generosity of benefits.

The United States is also in the redistributive regime, but at its edge: redistribution is weaker than in Europe and its fuzzy membership is lower. US employees work about 38 hours a week, close to Poland, which fits the long debate on why Americans work more than Europeans (Prescott 2004; Alesina, Glaeser and Sacerdote 2006).

Sweden, Denmark and Germany are the core of the regime: the strongest redistribution, a small gender gap and about 30 hours per worker.

China belongs to the low-redistribution, high-employment regime. Employees work long hours and so many people work that hours per adult are among the highest in the sample.

India is a typical male-breadwinner country, with a gender gap of about 40 points and the longest hours per worker among the selected countries.

South Africa is the clearest outlier. It has the highest market inequality in the data and is flagged by DBSCAN. Its employees work long hours, but only about 37% of adults are employed, so hours per adult are the lowest in the group. Long hours for those who work coexist with very low total labour input.

Conclusions

Five groups offer a useful summary of the institutional characteristics of the 156 countries, but the evidence does not establish five mutually exclusive economic types. Persistent homology does not reveal unusually separated components relative to the chosen permutation reference. Mapper identifies a large connected component, while the simulations suggest that overlapping concentrations fit the observed diagnostics better than the particular featureless continuum considered here. A branching continuum cannot be excluded.

The descriptive evidence supports H1. The redistributive group averages approximately 35 weekly hours per worker, compared with roughly 42–44 in several other groups. Its average market Gini is around 47, compared with around 40 in the low-redistribution group. The distinction concerns redistribution rather than uniformly low market inequality. The association rules provide descriptive support for H2. The typology has a higher adjusted R-squared than the cubic log-GDP benchmark (approximately 0.34 versus 0.18); adding GDP contributes little in this specification. These comparisons do not identify causal effects of institutions or income.

The distinction between hours per worker and hours per adult is particularly important in South Africa and in the male-breadwinner group, where long hours among employed people coexist with low aggregate labour input. Poland also illustrates the limits of the typology: its weekly hours exceed those in Germany and Sweden by about 7.5. The fitted model accounts for approximately three hours of this difference; the remainder suggests further investigation of part-time employment, productivity and collective bargaining rather than an identified causal mechanism.

Spatial analysis indicates dependence in working hours and in residuals from the regime model. Allowing for spatial dependence attenuates the estimated differences between groups, although these differences remain substantial. The results are also broadly similar across the five imputations. These checks strengthen the descriptive interpretation without resolving omitted-variable or measurement problems.

The study is cross-sectional and cannot establish causality. Source years differ, some countries have uncertain assignments, and the sample is modest for multivariate clustering. Further research could examine alternative spatial weights and constrained clustering (Kopczewska 2022), as well as repeat the classification over time using comparable panel data.

Declaration of tool use

I independently selected the research question, formulated the hypotheses and chose the data from my master’s thesis. AI tools (Claude and ChatGPT) were used solely for language editing and stylistic revision of the text. I reviewed the final manuscript and take full responsibility for its content, methodology and results. # References

Agrawal, R., Imieliński, T. and Swami, A. (1993). Mining association rules between sets of items in large databases. ACM SIGMOD Record, 22(2), 207–216.
Alesina, A., Glaeser, E. and Sacerdote, B. (2006). Work and leisure in the United States and Europe: Why so different? NBER Macroeconomics Annual 2005, 20.
Anselin, L. (1988). Spatial Econometrics: Methods and Models. Dordrecht: Kluwer.
Bell, L.A. and Freeman, R.B. (2001). The incentive for working hard: Explaining hours worked differences in the US and Germany. Labour Economics, 8(2), 181–202.
Bick, A., Fuchs-Schündeln, N. and Lagakos, D. (2018). How do hours worked vary with income? Cross-country evidence and implications. American Economic Review, 108(1), 170–199.
Blau, F.D. and Kahn, L.M. (2013). Female labor supply: Why is the United States falling behind? American Economic Review, 103(3), 251–256.
Bowles, S. and Park, Y. (2005). Emulation, inequality, and work hours: Was Thorsten Veblen right? Economic Journal, 115(507), F397–F412.
Brock, G., Pihur, V., Datta, S. and Datta, S. (2008). clValid: An R package for cluster validation. Journal of Statistical Software, 25(4), 1–22.
Burgoon, B. and Baxandall, P. (2004). Three worlds of working time: the partisan and welfare politics of work hours in industrialized countries. Politics & Society, 32(4), 439–473.
Carlsson, G. (2009). Topology and data. Bulletin of the American Mathematical Society, 46(2), 255–308.
van Buuren, S. and Groothuis-Oudshoorn, K. (2011). mice: Multivariate imputation by chained equations in R. Journal of Statistical Software, 45(3), 1–67.
van der Maaten, L. and Hinton, G. (2008). Visualizing data using t-SNE. Journal of Machine Learning Research, 9, 2579–2605.
Edelsbrunner, H., Letscher, D. and Zomorodian, A. (2002). Topological persistence and simplification. Discrete & Computational Geometry, 28(4), 511–533.
Esping-Andersen, G. (1990). The Three Worlds of Welfare Capitalism. Princeton: Princeton University Press.
Ester, M., Kriegel, H.-P., Sander, J. and Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. Proceedings of KDD-96, 226–231.
Gethin, A. and Saez, E. (2026). Global Working Hours. Quarterly Journal of Economics, 141(4), 3505–3565.
Hennig, C. (2007). Cluster-wise assessment of cluster stability. Computational Statistics & Data Analysis, 52(1), 258–271.
Horn, J.L. (1965). A rationale and test for the number of factors in factor analysis. Psychometrika, 30(2), 179–185.
Kaufman, L. and Rousseeuw, P.J. (1990). Finding Groups in Data: An Introduction to Cluster Analysis. New York: Wiley.
Kopczewska, K. (2022). Spatial machine learning: new opportunities for regional science. The Annals of Regional Science, 68, 713–755.
Kopczewska, K. (ed.) (2027). Applied Spatial Statistics and Econometrics: Data Analysis in R (2nd ed.). Abingdon: Routledge.
Kopczewska, K. and Ćwiakowski, P. (2021). Spatio-temporal stability of housing submarkets. Tracking spatial location of clusters of geographically weighted regression estimates of price determinants. Land Use Policy, 103, 105292.
Liu, B., Hsu, W. and Ma, Y. (1998). Integrating classification and association rule mining. Proceedings of KDD-98.
Moran, P.A.P. (1950). Notes on continuous stochastic phenomena. Biometrika, 37(1/2), 17–23.
Prescott, E.C. (2004). Why do Americans work so much more than Europeans? Federal Reserve Bank of Minneapolis Quarterly Review, 28(1), 2–13.
Ramsay, J.O. and Silverman, B.W. (2005). Functional Data Analysis (2nd ed.). New York: Springer.
Rubin, D.B. (1987). Multiple Imputation for Nonresponse in Surveys. New York: Wiley.
Singh, G., Mémoli, F. and Carlsson, G. (2007). Topological methods for the analysis of high dimensional data sets and 3D object recognition. Eurographics Symposium on Point-Based Graphics, 91–100.
Solt, F. (2020). Measuring income inequality across countries and over time: The Standardized World Income Inequality Database. Social Science Quarterly, 101(3), 1183–1199.
Tibshirani, R., Walther, G. and Hastie, T. (2001). Estimating the number of clusters in a data set via the gap statistic. Journal of the Royal Statistical Society: Series B, 63(2), 411–423.
GeoNames geographical database, geonames.org (capital city coordinates and land neighbours, via the geonamescache package).
Kopczewska, K. Unsupervised Learning, class materials, WNE UW 2026/27.

Session info

sessionInfo()
## R version 4.6.1 (2026-06-24 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 26300)
## 
## Matrix products: default
##   LAPACK version 3.12.1
## 
## locale:
## [1] LC_COLLATE=Polish_Poland.utf8  LC_CTYPE=Polish_Poland.utf8   
## [3] LC_MONETARY=Polish_Poland.utf8 LC_NUMERIC=C                  
## [5] LC_TIME=Polish_Poland.utf8    
## 
## time zone: Europe/Warsaw
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] arulesCBA_1.2.10 arulesViz_1.5.4  arules_1.7.15    Matrix_1.7-5    
##  [5] clValid_0.7      corrplot_0.95    mice_3.19.0      Rtsne_0.17      
##  [9] dbscan_1.3.0     factoextra_2.2.0 cluster_2.1.8.2  lubridate_1.9.5 
## [13] forcats_1.0.1    stringr_1.6.0    dplyr_1.2.1      purrr_1.2.2     
## [17] readr_2.2.0      tidyr_1.3.2      tibble_3.3.1     ggplot2_4.0.4   
## [21] tidyverse_2.0.0 
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3    wk_0.9.5              rstudioapi_0.19.0    
##   [4] jsonlite_2.0.0        shape_1.4.6.1         magrittr_2.0.5       
##   [7] TH.data_1.1-5         rainbow_3.8           jomo_2.7-6           
##  [10] farver_2.1.2          nloptr_2.2.1          rmarkdown_2.32       
##  [13] vctrs_0.7.3           spdep_1.4-3           memoise_2.0.1        
##  [16] minqa_1.2.8           rstatix_1.1.0         htmltools_0.5.9      
##  [19] broom_1.0.13          deSolve_1.42          s2_1.1.13            
##  [22] LearnBayes_2.15.2     Formula_1.2-6         mitml_0.4-5          
##  [25] sass_0.4.10           spData_2.3.5          hdrcde_3.5.0         
##  [28] pracma_2.4.6          KernSmooth_2.23-26    bslib_0.12.0         
##  [31] sandwich_3.1-3        zoo_1.9-1             cachem_1.1.0         
##  [34] ripserr_1.0.0         igraph_2.3.4          lifecycle_1.0.5      
##  [37] iterators_1.0.14      pkgconfig_2.0.3       R6_2.6.1             
##  [40] fastmap_1.2.0         rbibutils_2.4.1       digest_0.6.39        
##  [43] colorspace_2.1-4      ggpubr_1.0.0          labeling_0.4.3       
##  [46] spatialreg_1.4-3      timechange_0.4.0      polyclip_1.10-7      
##  [49] abind_1.4-8           compiler_4.6.1        proxy_0.4-29         
##  [52] withr_3.0.3           S7_0.2.2              backports_1.5.1      
##  [55] carData_3.0-6         viridis_0.6.5         DBI_1.3.0            
##  [58] ggforce_0.6.0         ggsignif_0.6.4        pan_2.0              
##  [61] MASS_7.3-65           classInt_0.4-11       tools_4.6.1          
##  [64] units_1.0-1           otel_0.3.0            nnet_7.3-20          
##  [67] glue_1.8.1            nlme_3.1-169          grid_4.6.1           
##  [70] sf_1.1-3              generics_0.1.4        gtable_0.3.6         
##  [73] fda_6.3.0             tzdb_0.5.0            class_7.3-23         
##  [76] data.table_1.18.6.1   hms_1.1.4             tidygraph_1.3.1      
##  [79] sp_2.2-4              car_3.1-5             ggrepel_0.9.8        
##  [82] foreach_1.5.2         pillar_1.11.1         splines_4.6.1        
##  [85] tweenr_2.0.3          lattice_0.22-9        survival_3.8-6       
##  [88] deldir_2.0-4          ks_1.15.3             tidyselect_1.2.1     
##  [91] fds_2.0               knitr_1.52            reformulas_0.4.4     
##  [94] gridExtra_2.3.1       stats4_4.6.1          xfun_0.62            
##  [97] graphlayouts_1.2.5    stringi_1.8.9         yaml_2.3.12          
## [100] boot_1.3-32           evaluate_1.0.5        codetools_0.2-20     
## [103] ggraph_2.2.2          cli_3.6.6             rpart_4.1.27         
## [106] Rdpack_2.6.6          jquerylib_0.1.4       Rcpp_1.1.2           
## [109] coda_0.19-4.1         mclust_6.1.4          marginaleffects_1.0.0
## [112] lme4_2.1-0            glmnet_5.2            viridisLite_0.4.3    
## [115] mvtnorm_1.4-2         scales_1.4.0          e1071_1.7-17         
## [118] pcaPP_2.0-7           rlang_1.3.0           multcomp_1.4-32