The primary comparison in the paper is between the three models
varying granularity (prototype, exemplar, and
adaptive, the last one being the model that infers its own
within-class granularity α). The fourth model, shared,
varies γ (cross-class sharing). Data are read from the five merged
cohort tables in ../model_output/; figures are written to
figures/.
library(tidyverse)
library(brms)
dir.create("figures", showWarnings = FALSE)
# Primary comparison = three granularity models (prototype, exemplar, adaptive).
primary_models <- c("prototype", "exemplar", "adaptive")
model_palette <- c("prototype" = "#39517D", "exemplar" = "#6E685D",
"adaptive" = "#D0742D", "shared" = "#4E9B8F")
proto_palette <- c("A" = "#284958", "B" = "#C3824B")
trial_block_scale <- scale_x_continuous(breaks = 0:10, limits = c(0, 10))
# Learner inclusion is a screening decision: keep a
# participant if P(exception-accuracy slope > 0) exceeds PRIMARY_THRESHOLD. 0.75
# sits in the natural gap in the ranked improvements (§2a)
PRIMARY_THRESHOLD <- 0.75
SENSITIVITY_THRESHOLDS <- c(0.75, 0.80, 0.85, 0.90, 0.95)
The five merged cohort tables cover 43 participants and four models
(prototype, exemplar, adaptive,
shared).
model_output_dir <- "../model_output"
read_table <- function(name)
read_csv(file.path(model_output_dir, paste0(name, ".csv")), show_col_types = FALSE)
resp_raw <- read_table("responses_and_model_predictions")
ll_raw <- read_table("model_segment_log_likelihoods")
params_raw <- read_table("fitted_params")
member_raw <- read_table("cluster_membership")
consen_raw <- read_table("cluster_consensus")
a_words <- c("gyvuco", "zyvuco", "gybuco", "gyveco", "gyvuto", "gyvuci")
b_words <- c("zabeti", "gabeti", "zybeti", "zaveti", "zabuti", "zabeto")
exceptions <- c("gavuco", "zabeci")
# suffix classes (the class a word's CORRECT plural belongs to)
re_class <- c(b_words, "gavuco") # correct suffix -re
ma_class <- c(a_words, "zabeci") # correct suffix -ma
word_class <- function(w) ifelse(w %in% re_class, "re", "ma")
add_stim_vars <- function(d) {
d %>% mutate(
stimulus_type = relevel(
factor(ifelse(word %in% exceptions, "exception", "prototypical")),
ref = "prototypical"),
correct_suffix = case_when(
word == "gavuco" ~ "re", word == "zabeci" ~ "ma",
word %in% a_words ~ "ma", word %in% b_words ~ "re"),
prototype = case_when(
word == "gavuco" ~ "A", word == "zabeci" ~ "B",
word %in% a_words ~ "A", word %in% b_words ~ "B"),
human_correct = as.integer(human_response == correct_suffix)
)
}
resp <- resp_raw %>%
mutate(trial_block = Trial / 2) %>%
add_stim_vars()
ll <- ll_raw
params <- params_raw
consen <- consen_raw
member <- member_raw
# ALL model-prediction rows (needed for §6); adds fit quantities.
preds <- resp %>%
filter(!is.na(model)) %>%
mutate(
p_human = ifelse(human_response == "re", P_re, P_ma),
p_correct = ifelse(correct_suffix == "re", P_re, P_ma),
log_lik = log(pmax(p_human, 1e-10)),
is_right = as.integer((human_response == "re" & P_re > P_ma) |
(human_response == "ma" & P_ma > P_re))
)
# primary prediction table: three granularity models only.
preds_p <- preds %>%
filter(model %in% primary_models) %>%
mutate(model = factor(model, levels = primary_models))
# One row per actual observation (dedupe the 4x model duplication), all 20 blocks.
human <- resp %>%
distinct(PROLIFIC_PID, Trial, trial_block, word,
human_response, stimulus_type, prototype, correct_suffix, human_correct)
Fitted parameters for the three granularity models (α applies to
adaptive only):
params %>%
filter(model %in% primary_models) %>%
mutate(model = factor(model, levels = primary_models)) %>%
group_by(model) %>%
summarise(mean_mu = mean(mu), mean_guessing = mean(guessing),
mean_alpha = mean(mean_alpha, na.rm = TRUE), .groups = "drop")
## # A tibble: 3 × 4
## model mean_mu mean_guessing mean_alpha
## <fct> <dbl> <dbl> <dbl>
## 1 prototype 17.5 0.272 NaN
## 2 exemplar 1.81 0.151 NaN
## 3 adaptive 13.5 0.237 0.328
The by-word plot shows the progressive polarisation of prototypical stimuli and the slower inversion of the exceptions. The table beneath ranks stimuli by mean accuracy.
databyword_all <- human %>%
filter(Trial %% 2 == 0) %>%
group_by(trial_block, prototype, stimulus_type, word) %>%
summarise(mean.acc.binary = mean(human_correct), .groups = "drop") %>%
mutate(mean.str1.hits = case_when(
stimulus_type == "exception" & prototype == "A" ~ 1 - mean.acc.binary,
stimulus_type == "exception" & prototype == "B" ~ mean.acc.binary,
prototype == "A" ~ mean.acc.binary,
TRUE ~ 1 - mean.acc.binary))
ggplot(databyword_all, aes(trial_block, mean.str1.hits,
group = word, color = prototype, shape = stimulus_type)) +
geom_point() +
geom_line(data = filter(databyword_all, stimulus_type == "prototypical"),
linetype = "dashed", alpha = 0.3) +
geom_line(data = filter(databyword_all, stimulus_type == "exception")) +
scale_color_manual(values = proto_palette) +
trial_block_scale +
labs(y = "% 'gyvuco' suffix", shape = "is.exception", x = "Trial block") +
theme_minimal(22)
ggsave("figures/raw-data-everyone.pdf", width = 9, height = 7)
databyword_all %>%
group_by(word, stimulus_type, prototype) %>%
summarise(x = mean(mean.acc.binary), .groups = "drop") %>%
arrange(x)
## # A tibble: 14 × 4
## word stimulus_type prototype x
## <chr> <fct> <chr> <dbl>
## 1 gavuco exception A 0.407
## 2 zabeci exception B 0.563
## 3 zabeto prototypical B 0.570
## 4 gyvuci prototypical A 0.693
## 5 gyvuto prototypical A 0.763
## 6 zyvuco prototypical A 0.777
## 7 gyvuco prototypical A 0.798
## 8 zabuti prototypical B 0.8
## 9 gybuco prototypical A 0.805
## 10 gyveco prototypical A 0.807
## 11 zybeti prototypical B 0.807
## 12 gabeti prototypical B 0.821
## 13 zabeti prototypical B 0.849
## 14 zaveti prototypical B 0.856
We keep participants who show improvement on the exceptions: a logistic model on exception trials with a by-participant random slope for centred Trial. We read P(slope > 0) for each participant off the posterior draws, so any threshold applies from the single fit.
exceptions_df <- human %>%
filter(stimulus_type == "exception") %>%
mutate(trial_c = Trial - mean(Trial))
learning_model <- brm(
human_correct ~ 0 + (trial_c | PROLIFIC_PID),
data = exceptions_df, family = bernoulli(),
cores = 4, iter = 4000, silent = 2, refresh = 0
)
# With no population-level term, coef() == ranef() (the random slope IS the slope).
sl_draws <- coef(learning_model, summary = FALSE)$PROLIFIC_PID[, , "trial_c"]
learner_status <- tibble(
PROLIFIC_PID = colnames(sl_draws),
slope = colMeans(sl_draws),
p_pos = colMeans(sl_draws > 0) # P(slope > 0)
) %>% arrange(desc(p_pos))
pick_learners <- function(th = PRIMARY_THRESHOLD)
learner_status$PROLIFIC_PID[learner_status$p_pos > th]
learner_ids <- pick_learners(PRIMARY_THRESHOLD)
# retained count at each threshold
tibble(threshold = SENSITIVITY_THRESHOLDS) %>%
mutate(n_retained = map_int(threshold, ~ length(pick_learners(.x))))
## # A tibble: 5 × 2
## threshold n_retained
## <dbl> <int>
## 1 0.75 17
## 2 0.8 17
## 3 0.85 13
## 4 0.9 12
## 5 0.95 10
The cut-off falls in a natural break in the data. Ranked by P(slope > 0), the retained participants sit above a visible gap before the exceedances decay toward zero. The table lists the largest gaps and the plot marks where the 0.75 cutoff is.
gap_df <- learner_status %>%
mutate(rank = row_number(), gap_below = p_pos - lead(p_pos))
gap_df %>% filter(!is.na(gap_below)) %>%
slice_max(gap_below, n = 5) %>%
transmute(between_rank = paste0(rank, "-", rank + 1),
upper = round(p_pos, 3),
lower = round(p_pos - gap_below, 3),
gap = round(gap_below, 3))
## # A tibble: 5 × 4
## between_rank upper lower gap
## <chr> <dbl> <dbl> <dbl>
## 1 35-36 0.373 0.279 0.094
## 2 36-37 0.279 0.22 0.06
## 3 41-42 0.103 0.046 0.057
## 4 17-18 0.803 0.75 0.054
## 5 34-35 0.426 0.373 0.053
ggplot(gap_df, aes(rank, p_pos)) +
geom_hline(yintercept = PRIMARY_THRESHOLD, linetype = "dashed",
color = "#C3824B", linewidth = 1) +
geom_point(aes(color = p_pos > PRIMARY_THRESHOLD), size = 2.4) +
scale_color_manual(values = c(`TRUE` = "#39517D", `FALSE` = "grey65"), guide = "none") +
scale_y_continuous(limits = c(0, 1), breaks = seq(0, 1, 0.25)) +
labs(x = "Participant (ranked by P(slope>0))", y = "P(exception slope > 0)",
subtitle = paste0("dashed = ", PRIMARY_THRESHOLD, " cut | retained = ",
length(learner_ids), " of ", nrow(learner_status))) +
theme_minimal(16)
ggsave("figures/learner-gap.pdf", width = 9, height = 5)
For each learner set (all participants, then P(slope>0) > 0.75
/ 0.80 / 0.85 / 0.90 / 0.95) we recompute the best-fitting-model counts
and the summed log-likelihood ordering of the three models. The ordering
is stable across thresholds: prototype is always worst, and
adaptive/exemplar trade the top spot depending
on the aggregate-vs-per-participant tension discussed in §3.
best_fit_dist <- function(ids) {
preds_p %>% filter(PROLIFIC_PID %in% ids) %>%
group_by(PROLIFIC_PID, model) %>% summarise(total_ll = sum(log_lik), .groups = "drop") %>%
group_by(PROLIFIC_PID) %>% slice_max(total_ll, n = 1, with_ties = FALSE) %>%
ungroup() %>% count(best_model = model, .drop = FALSE)
}
ll_ordering <- function(ids) {
preds_p %>% filter(PROLIFIC_PID %in% ids) %>%
group_by(model) %>% summarise(summed_ll = sum(log_lik), .groups = "drop") %>%
arrange(desc(summed_ll))
}
sets <- c(list(`keep all` = unique(preds_p$PROLIFIC_PID)),
setNames(lapply(SENSITIVITY_THRESHOLDS, pick_learners),
paste0("p>", format(SENSITIVITY_THRESHOLDS))))
# best-fit model counts by learner set
imap(sets, ~ best_fit_dist(.x) %>% mutate(set = .y)) %>%
bind_rows() %>%
pivot_wider(names_from = set, values_from = n, values_fill = 0)
## # A tibble: 3 × 7
## best_model `keep all` `p>0.75` `p>0.80` `p>0.85` `p>0.90` `p>0.95`
## <fct> <int> <int> <int> <int> <int> <int>
## 1 prototype 6 0 0 0 0 0
## 2 exemplar 18 4 4 2 2 0
## 3 adaptive 19 13 13 11 10 10
# summed-LL model ordering by learner set
imap(sets, ~ ll_ordering(.x) %>% mutate(set = .y, rank = row_number())) %>%
bind_rows() %>% select(set, rank, model, summed_ll) %>% arrange(set, rank)
## # A tibble: 18 × 4
## set rank model summed_ll
## <chr> <int> <fct> <dbl>
## 1 keep all 1 exemplar -3109.
## 2 keep all 2 adaptive -3182.
## 3 keep all 3 prototype -3453.
## 4 p>0.75 1 exemplar -1056.
## 5 p>0.75 2 adaptive -1062.
## 6 p>0.75 3 prototype -1286.
## 7 p>0.80 1 exemplar -1056.
## 8 p>0.80 2 adaptive -1062.
## 9 p>0.80 3 prototype -1286.
## 10 p>0.85 1 adaptive -710.
## 11 p>0.85 2 exemplar -736.
## 12 p>0.85 3 prototype -911.
## 13 p>0.90 1 adaptive -628.
## 14 p>0.90 2 exemplar -654.
## 15 p>0.90 3 prototype -828.
## 16 p>0.95 1 adaptive -521.
## 17 p>0.95 2 exemplar -546.
## 18 p>0.95 3 prototype -684.
tibble(threshold = names(sets), n_learners = lengths(sets)) %>%
mutate(threshold = factor(threshold, levels = names(sets))) %>%
ggplot(aes(threshold, n_learners)) +
geom_col(fill = "#39517D") +
geom_text(aes(label = n_learners), vjust = -0.4) +
labs(x = "Inclusion threshold", y = "Participants retained") +
theme_minimal(16)
ggsave("figures/threshold-sensitivity.pdf", width = 8, height = 5)
preds_pL <- preds_p %>% filter(PROLIFIC_PID %in% learner_ids) # 3 models, learners
preds_L <- preds %>% filter(PROLIFIC_PID %in% learner_ids) # all 4 models, learners (§6)
human_L <- human %>% filter(PROLIFIC_PID %in% learner_ids)
ll_L <- ll %>% filter(PROLIFIC_PID %in% learner_ids)
consen_L <- consen %>% filter(PROLIFIC_PID %in% learner_ids)
Raw data, learners only:
databyword <- human_L %>%
filter(Trial %% 2 == 0) %>%
group_by(trial_block, prototype, stimulus_type, word) %>%
summarise(mean.acc.binary = mean(human_correct), .groups = "drop") %>%
mutate(mean.str1.hits = case_when(
stimulus_type == "exception" & prototype == "A" ~ 1 - mean.acc.binary,
stimulus_type == "exception" & prototype == "B" ~ mean.acc.binary,
prototype == "A" ~ mean.acc.binary,
TRUE ~ 1 - mean.acc.binary))
ggplot(databyword, aes(trial_block, mean.str1.hits,
group = word, color = prototype, shape = stimulus_type)) +
geom_point() +
geom_line(data = filter(databyword, stimulus_type == "prototypical"),
linetype = "dashed", alpha = 0.3) +
geom_line(data = filter(databyword, stimulus_type == "exception")) +
scale_color_manual(values = proto_palette) +
trial_block_scale +
labs(y = "% -ma suffix", shape = "is.exception", x = "Trial block") +
theme_minimal(25)
ggsave("figures/raw-data-successful-learners.pdf", width = 9, height = 5)
Accuracy over time by stimulus type (positive Trial slope; large negative exception offset; positive interaction — exceptions start worse but improve faster):
mod1 <- brm(human_correct ~ Trial * stimulus_type + (1 | PROLIFIC_PID),
data = human_L, family = bernoulli(),
cores = 4, iter = 4000, silent = 2, refresh = 0)
summary(mod1)
## Family: bernoulli
## Links: mu = logit
## Formula: human_correct ~ Trial * stimulus_type + (1 | PROLIFIC_PID)
## Data: human_L (Number of observations: 4760)
## Draws: 4 chains, each with iter = 4000; warmup = 2000; thin = 1;
## total post-warmup draws = 8000
##
## Multilevel Hyperparameters:
## ~PROLIFIC_PID (Number of levels: 17)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 0.79 0.16 0.55 1.17 1.00 1369 2657
##
## Regression Coefficients:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 0.94 0.20 0.53 1.35 1.00 1252
## Trial 0.07 0.01 0.06 0.09 1.00 4439
## stimulus_typeexception -1.68 0.19 -2.05 -1.31 1.00 3063
## Trial:stimulus_typeexception 0.06 0.02 0.03 0.09 1.00 2852
## Tail_ESS
## Intercept 1715
## Trial 5453
## stimulus_typeexception 4805
## Trial:stimulus_typeexception 4379
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
conditional_effects(mod1, effect = "Trial:stimulus_type")[[1]] %>%
mutate(trial_block = Trial / 2) %>%
ggplot(aes(trial_block, estimate__, fill = stimulus_type, color = stimulus_type)) +
geom_ribbon(aes(ymax = upper__, ymin = lower__), alpha = .5, color = NA) +
geom_line(linewidth = 1.4) +
trial_block_scale +
labs(y = "is.correct", x = "Trial block",
fill = "is.exception", color = "is.exception") +
theme_minimal(22)
ggsave("figures/model-inference.pdf", width = 9, height = 7)
Predicted probability of the intended suffix. All models start strong on prototypes; the prototype model’s exception accuracy declines with training, while the adaptive model’s improves.
preds_pL %>%
filter(Trial %% 2 == 0) %>%
group_by(model, stimulus_type, trial_block) %>%
summarise(avg_pcorrect = mean(p_correct), .groups = "drop") %>%
ggplot(aes(trial_block, avg_pcorrect, color = model, linetype = stimulus_type)) +
geom_point() + geom_line() +
scale_color_manual(values = model_palette) +
trial_block_scale + theme_minimal(25) +
labs(x = "Trial block", y = "Predicted probability of\nintended suffix",
color = "Model", linetype = "Stimulus type")
ggsave("figures/overall-model-prediction.pdf", width = 9, height = 5)
Summed log-likelihood by stimulus type. The three models are close on prototypes; on exceptions the prototype model gets progressively less accurate as it grows confidently wrong.
preds_pL %>%
filter(Trial %% 2 == 0) %>%
group_by(model, trial_block, stimulus_type) %>%
summarise(mean_ll = sum(log_lik), .groups = "drop") %>%
ggplot(aes(trial_block, mean_ll, colour = model)) +
geom_point() + geom_line() +
scale_color_manual(values = model_palette) +
trial_block_scale +
facet_wrap(~stimulus_type, scales = "free_y") +
labs(y = "Summed Log Likelihood", x = "Trial block") +
theme_minimal(22)
ggsave("figures/ll-by-stimulus.pdf", width = 11, height = 7)
Log-likelihood is asymmetric — it punishes confident errors without bound but bounds the reward for confident hits — so it rewards hedging near 0.5:
tibble(p = seq(0.001, 0.999, length.out = 100)) %>%
mutate(value = log(p)) %>%
ggplot(aes(p, value)) +
geom_line(size = 1) +
geom_hline(yintercept = 0, color = "black", size = 0.2) +
geom_vline(xintercept = 0.5, color = "gray", linetype = "dotted") +
labs(x = "Probability (p)", y = "Log-Likelihood Value") +
theme_minimal(22)
ggsave("figures/log-likelihood-plot.pdf", width = 7, height = 5)
Mean probability assigned to the human’s actual choice (symmetric complement to LL): the adaptive model leads on exceptions.
preds_pL %>%
filter(Trial %% 2 == 0) %>%
group_by(trial_block, model, stimulus_type) %>%
summarise(avg_p_human = mean(p_human), .groups = "drop") %>%
ggplot(aes(trial_block, avg_p_human, color = model, linetype = stimulus_type)) +
geom_point() + geom_line() +
scale_color_manual(values = model_palette) +
trial_block_scale +
labs(y = "Mean P(human choice)", x = "Trial block",
linetype = "Stimulus type", color = "Model") +
theme_minimal(25)
ggsave("figures/probability-of-human-choice.pdf", width = 9, height = 5)
Mean log-likelihood and mean probability assigned to the human’s response (higher is better), plus MAP accuracy, by model and stimulus type. This is the source for the model-fit table in the paper: the three models are near-identical on the prototypical stimuli, while on the exceptions the adaptive model leads on every measure and the prototype model does poorly.
preds_pL %>%
group_by(model, stimulus_type) %>%
summarise(mean_ll = mean(log_lik),
mean_p_human = mean(p_human),
acc_MAP = mean(is_right), .groups = "drop") %>%
arrange(stimulus_type, desc(mean_p_human))
## # A tibble: 6 × 5
## model stimulus_type mean_ll mean_p_human acc_MAP
## <fct> <fct> <dbl> <dbl> <dbl>
## 1 adaptive prototypical -0.426 0.759 0.826
## 2 exemplar prototypical -0.415 0.740 0.826
## 3 prototype prototypical -0.433 0.727 0.826
## 4 adaptive exception -0.571 0.624 0.691
## 5 exemplar exception -0.615 0.579 0.644
## 6 prototype exception -1.18 0.396 0.35
Overall best-fitting model per participant (the table below): no one is best fit by the prototype model; participants split between exemplar and adaptive.
participant_best_overall <- preds_pL %>%
group_by(PROLIFIC_PID, model) %>% summarise(total_ll = sum(log_lik), .groups = "drop") %>%
group_by(PROLIFIC_PID) %>% slice_max(total_ll, n = 1, with_ties = FALSE) %>%
ungroup() %>% select(PROLIFIC_PID, best_model = model)
preds_pL <- preds_pL %>% left_join(participant_best_overall, by = "PROLIFIC_PID")
participant_best_overall %>% count(best_model, .drop = FALSE)
## # A tibble: 3 × 2
## best_model n
## <fct> <int>
## 1 prototype 0
## 2 exemplar 4
## 3 adaptive 13
Best-fitting model shifts from prototype toward adaptive/exemplar as evidence accumulates:
cumulative_best <- preds_pL %>%
filter(Trial %% 2 == 0) %>%
arrange(PROLIFIC_PID, model, iteration) %>%
group_by(PROLIFIC_PID, model, iteration) %>%
summarise(segment_ll = sum(log_lik), .groups = "drop") %>%
group_by(PROLIFIC_PID, model) %>%
mutate(cumulative_ll = cumsum(segment_ll)) %>%
group_by(PROLIFIC_PID, iteration) %>%
slice_max(cumulative_ll, n = 1, with_ties = FALSE) %>%
ungroup()
cumulative_best %>%
mutate(trial_block = iteration) %>%
count(trial_block, model, .drop = FALSE) %>%
ggplot(aes(trial_block, n, fill = model)) +
geom_col(position = "stack") +
scale_fill_manual(values = model_palette, limits = primary_models) +
scale_x_continuous(breaks = 0:10) + coord_cartesian(xlim = c(0, 10)) +
labs(x = "Trial block", y = "Participants", fill = "Best model\n(cumulative)") +
theme_minimal(25)
ggsave("figures/best-cumulative-model.pdf", width = 9, height = 5)
Behaviour of participants grouped by best-fitting model, and their mean guessing rate (exemplar-best participants guess more and hover near chance on exceptions):
human_L %>%
left_join(participant_best_overall, by = "PROLIFIC_PID") %>%
filter(Trial %% 2 == 0) %>%
group_by(best_model, trial_block, stimulus_type) %>%
summarise(accuracy = mean(human_correct), n = n(), .groups = "drop") %>%
ggplot(aes(trial_block, accuracy, color = best_model, shape = stimulus_type)) +
geom_point() + geom_line() +
scale_color_manual(values = model_palette) +
trial_block_scale + facet_wrap(~best_model) +
labs(title = "Participant best fit by...", x = "Trial block",
y = "Human accuracy", color = "Best-fit model", shape = "Stimulus type") +
theme_minimal(16)
ggsave("figures/performance-by-best-model.pdf", width = 11, height = 6)
# Mean guessing rate by best-fit model (learners; averaged over the 3 primary
# models per participant, then over participants in each best-fit group).
# Supplies [X] (exemplar) and [Y] (adaptive) for the text.
params %>%
filter(model %in% primary_models, PROLIFIC_PID %in% learner_ids) %>%
group_by(PROLIFIC_PID) %>%
summarise(mean_guessing = mean(guessing), .groups = "drop") %>%
inner_join(participant_best_overall, by = "PROLIFIC_PID") %>%
group_by(best_model) %>%
summarise(mean_guessing = round(mean(mean_guessing), 3),
n = n(), .groups = "drop") %>%
arrange(desc(mean_guessing))
## # A tibble: 2 × 3
## best_model mean_guessing n
## <fct> <dbl> <int>
## 1 exemplar 0.222 4
## 2 adaptive 0.179 13
Number of clusters the adaptive model infers over learning — starting near the two prototype clusters and growing as the exceptions are accommodated:
ll_L %>%
filter(model == "adaptive") %>%
group_by(iteration) %>%
summarise(mean_clusters = mean(total_clusters),
se = sd(total_clusters) / sqrt(n()), .groups = "drop") %>%
mutate(trial_block = iteration) %>%
ggplot(aes(trial_block, mean_clusters)) +
geom_ribbon(aes(ymin = mean_clusters - se, ymax = mean_clusters + se),
alpha = 0.2, fill = model_palette["adaptive"]) +
geom_point(color = model_palette["adaptive"]) +
geom_line(color = model_palette["adaptive"]) +
trial_block_scale +
labs(x = "Trial block", y = "Total clusters") +
theme_minimal(16)
ggsave("figures/clusters-over-training.pdf", width = 9, height = 7)
cluster_consensus gives, per (participant, segment) and
word pair, the fraction of posterior samples in which the two words
share a dish (label-switching invariant); we average over learners and
show early / mid / late segments.
word_order <- c(a_words, "gavuco", b_words, "zabeci")
consensus_mean <- consen_L %>%
filter(model == "adaptive") %>%
group_by(iteration, word_a, word_b) %>%
summarise(p_coassign = mean(p_coassign), .groups = "drop")
# symmetric long form (incl. diagonal = 1) for one segment
heat_seg <- function(seg) {
d <- consensus_mean %>% filter(iteration == seg)
bind_rows(d,
d %>% rename(word_a = word_b, word_b = word_a),
tibble(iteration = seg, word_a = word_order,
word_b = word_order, p_coassign = 1))
}
seg_labels <- c(`1` = "Segment 1 (early)",
`5` = "Segment 5 (mid)",
`10` = "Segment 10 (late)")
heat <- bind_rows(lapply(c(1, 5, 10), heat_seg)) %>%
mutate(word_a = factor(word_a, levels = word_order),
word_b = factor(word_b, levels = rev(word_order)),
panel = factor(seg_labels[as.character(iteration)],
levels = unname(seg_labels)))
ggplot(heat, aes(word_a, word_b, fill = p_coassign)) +
geom_tile(color = "white") +
scale_fill_viridis_c(limits = c(0, 1)) +
facet_wrap(~panel) +
coord_equal() +
labs(x = NULL, y = NULL, fill = "P(co-assign)") +
theme_minimal(11) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
ggsave("figures/consensus-heatmap.pdf", width = 13, height = 5)
An exception and its phonological group take different suffixes, so within the adaptive model (no cross-class sharing) they cannot share a dish; but we can ask whether the exception first gets lumped with the prototypical words of its own suffix class and then splits off. We track (i) co-assignment with the words that share a suffix class with it (gavuco↔︎b_words, zabeci↔︎a_words) and (ii) an isolation index (1 − mean co-assignment with all partners). The first falls and the second rises, i.e. the exceptions do progressively form their own cluster.
pair_long <- consen_L %>%
filter(model == "adaptive") %>%
bind_rows(consen_L %>% filter(model == "adaptive") %>%
rename(word_a = word_b, word_b = word_a))
is_suffix_mate <- function(ex, w)
(ex == "gavuco" & w %in% b_words) | (ex == "zabeci" & w %in% a_words)
detach_own <- pair_long %>%
filter(word_a %in% exceptions, is_suffix_mate(word_a, word_b)) %>%
group_by(iteration, exception = word_a) %>%
summarise(coassign_suffix_mates = mean(p_coassign), .groups = "drop")
isolation <- pair_long %>%
filter(word_a %in% exceptions) %>%
group_by(iteration, exception = word_a) %>%
summarise(isolation = 1 - mean(p_coassign), .groups = "drop")
left_join(detach_own, isolation, by = c("iteration", "exception")) %>%
pivot_longer(c(coassign_suffix_mates, isolation),
names_to = "metric", values_to = "value") %>%
mutate(trial_block = iteration,
metric = recode(metric,
coassign_suffix_mates = "co-assign w/ suffix-class mates",
isolation = "isolation index")) %>%
ggplot(aes(trial_block, value, color = exception)) +
geom_point() + geom_line() +
facet_wrap(~metric) + trial_block_scale +
labs(x = "Trial block", y = NULL, color = "Exception") +
theme_minimal(16)
ggsave("figures/exception-detachment.pdf", width = 11, height = 6)
sessionInfo()
## R version 4.6.1 (2026-06-24)
## Platform: aarch64-apple-darwin23
## Running under: macOS Sequoia 15.4.1
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: Europe/Rome
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] brms_2.23.0 Rcpp_1.1.2 lubridate_1.9.5 forcats_1.0.1
## [5] stringr_1.6.0 dplyr_1.2.1 purrr_1.2.2 readr_2.2.0
## [9] tidyr_1.3.2 tibble_3.3.1 ggplot2_4.0.3 tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] gtable_0.3.6 tensorA_0.36.2.1 xfun_0.60
## [4] bslib_0.11.0 lattice_0.22-9 tzdb_0.5.0
## [7] vctrs_0.7.3 tools_4.6.1 generics_0.1.4
## [10] parallel_4.6.1 pkgconfig_2.0.3 Matrix_1.7-5
## [13] checkmate_2.3.4 RColorBrewer_1.1-3 S7_0.2.2
## [16] distributional_0.8.1 RcppParallel_5.1.11-2 lifecycle_1.0.5
## [19] compiler_4.6.1 farver_2.1.2 textshaping_1.0.5
## [22] Brobdingnag_1.2-9 htmltools_0.5.9 sass_0.4.10
## [25] bayesplot_1.15.0 yaml_2.3.12 pillar_1.11.1
## [28] crayon_1.5.3 jquerylib_0.1.4 cachem_1.1.0
## [31] bridgesampling_1.2-1 abind_1.4-8 nlme_3.1-169
## [34] posterior_1.7.0 tidyselect_1.2.1 digest_0.6.39
## [37] mvtnorm_1.4-1 stringi_1.8.7 labeling_0.4.3
## [40] fastmap_1.2.0 grid_4.6.1 cli_3.6.6
## [43] magrittr_2.0.5 loo_2.10.0 utf8_1.2.6
## [46] withr_3.0.3 scales_1.4.0 backports_1.5.1
## [49] bit64_4.8.2 timechange_0.4.0 rmarkdown_2.31
## [52] matrixStats_1.5.0 bit_4.6.0 otel_0.2.0
## [55] ragg_1.5.2 hms_1.1.4 coda_0.19-4.1
## [58] evaluate_1.0.5 knitr_1.51 viridisLite_0.4.3
## [61] rstantools_2.6.0 rlang_1.3.0 glue_1.8.1
## [64] rstudioapi_0.19.0 vroom_1.7.1 jsonlite_2.0.0
## [67] R6_2.6.1 systemfonts_1.3.2