Statistical analysis

Bioacoustics stimuli for L2 learning

Author
Published

August 1, 2024

Source code and data found at https://github.com/maRce10/bioacoustics_and_L2_learning

Purpose

  • Run stats on L2 test using bioacoustic stimuli

Analysis flowchart

flowchart
  A[Read data] --> C(Format data) 
  C --> D(Statistical analysis)
  D --> E(Model summary) 

style A fill:#44015466
style C fill:#26828E4D
style D fill:#6DCD594D

Load packages

Code
# knitr is require for creating html/pdf/word reports formatR is
# used for soft-wrapping code

# install/ load packages
sketchy::load_packages(packages = c("lme4", "psych", "sjPlot", "corrplot",
    "readxl", "Hmisc", "brms", "emmeans", "viridis"))

source("~/Dropbox/R_package_testing/brmsish/R/helpers.R")
source("~/Dropbox/R_package_testing/brmsish/R/extended_summary.R")

1 Read data

Code
dat_day_1 <- read_excel("./data/raw/UCREA_day1_R.xlsx")

dat_day_2_online <- read_excel("./data/raw/UCREA_day2_LDT_R (2).xlsx",
    sheet = "Day 2_no_fillers_LDT")

dat_day_3_online <- read_excel("./data/raw/UCREA_day3_LDT_Acu_FINAL (1).xlsx")

dat_day_2_pldt <- read_excel("./data/raw/PLDT_day2RT_processed (1).xlsx")

dat_day_3_pldt <- read_excel("./data/raw/PLDT_day3_R_FINAL (1).xlsx",
    sheet = "Data")

dat_day_2_pldt_accu <- read_excel("./data/raw/PLDT_day2_Accu_FINAL (2).xlsx")

dat_day_2_ldt_accu <- read_excel("./data/raw/UCREA_day2_LDT_Acu_R_FINAL.xlsx")

2 Regression models

2.1 Recognition

Code
dat_day_1$condition_f <- factor(as.character(dat_day_1$Condition))
dat_day_1$ID <- factor(as.character(dat_day_1$ID))

levels(dat_day_1$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_1$L1_f <- factor(as.character(dat_day_1$L1))

levels(dat_day_1$L1_f) <- c("Native", "Non-native")

dat_day_1$vocab_sc <- scale(dat_day_1$vocab)

priors <- c(prior(normal(0, 4), class = "b"))
priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_recognition <- brm(formula = Recog ~ condition_f * L1_f + vocab_sc + (1 | ID) + (1 | nonword), family = bernoulli(), iter = 5000, chains = chains, cores = chains, data = dat_day_1, backend = "cmdstanr", file = "./data/processed/regression_model_day_1_recognition", prior = priors)

mod_recall <- brm(formula = Recall ~ condition_f * L1_f + vocab_sc + (1 | ID) + (1 | nonword), family = bernoulli(), iter = 5000, chains = chains, cores = chains, data = dat_day_1, backend = "cmdstanr", file = "./data/processed/regression_model_day_1_recall", prior = priors)
Code
mod_recognition <- readRDS("./data/processed/regression_model_day_1_recognition.rds")

extended_summary(fit = mod_recognition, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) Recog ~ condition_f * L1_f + vocab_sc + (1 | ID) + (1 | nonword) 5000 4 1 2500 0 (0%) 0 2238.147 3252.833 1705562512
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_condition_fBioacoustic 0.036 -0.115 0.186 1 7618.156 7069.694
b_condition_fCombined -0.109 -0.261 0.042 1 7691.938 7319.554
b_L1_fNonMnative 1.788 0.553 3.015 1 2238.147 3252.833
b_vocab_sc 0.569 -0.032 1.194 1.002 2253.444 3384.252
b_condition_fBioacoustic:L1_fNonMnative 0.271 0.015 0.524 1 7589.483 7031.423
b_condition_fCombined:L1_fNonMnative 0.195 -0.054 0.448 1 7465.676 7166.322

2.1.1 Contrasts

2.1.1.1 Full table

Code
contrasts_recognition <- as.data.frame(emmeans(mod_recognition, pairwise ~
    condition_f * L1_f)$contrasts)

names(contrasts_recognition)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_recognition, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic Native - Bioacoustic Native -0.037 -0.189 0.112
2 Linguistic Native - Combined Native 0.108 -0.034 0.266
3 Linguistic Native - (Linguistic Non-native) -1.786 -2.980 -0.527
4 Linguistic Native - (Bioacoustic Non-native) -2.092 -3.293 -0.849
5 Linguistic Native - (Combined Non-native) -1.870 -3.053 -0.598
6 Bioacoustic Native - Combined Native 0.145 -0.009 0.291
7 Bioacoustic Native - (Linguistic Non-native) -1.749 -2.969 -0.511
8 Bioacoustic Native - (Bioacoustic Non-native) -2.057 -3.273 -0.818
9 Bioacoustic Native - (Combined Non-native) -1.834 -3.022 -0.563
10 Combined Native - (Linguistic Non-native) -1.894 -3.063 -0.626
11 Combined Native - (Bioacoustic Non-native) -2.202 -3.379 -0.937
12 Combined Native - (Combined Non-native) -1.978 -3.195 -0.746
13 (Linguistic Non-native) - (Bioacoustic Non-native) -0.308 -0.518 -0.108
14 (Linguistic Non-native) - (Combined Non-native) -0.087 -0.289 0.115
15 (Bioacoustic Non-native) - (Combined Non-native) 0.221 0.011 0.424

2.1.1.2 Subset native vs non-native

Code
contrasts_recognition$first <- sapply(strsplit(contrasts_recognition$contrast,
    " - "), "[[", 1)
contrasts_recognition$second <- sapply(strsplit(contrasts_recognition$contrast,
    " - "), "[[", 2)

contrasts_recognition <- contrasts_recognition[!grepl("Non-native",
    contrasts_recognition$first) & grepl("Non-native", contrasts_recognition$second),
    ]

coef_table <- html_format_coef_table(contrasts_recognition[, 1:4],
    highlight = TRUE, fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
3 Linguistic Native - (Linguistic Non-native) -1.786 -2.980 -0.527
4 Linguistic Native - (Bioacoustic Non-native) -2.092 -3.293 -0.849
5 Linguistic Native - (Combined Non-native) -1.870 -3.053 -0.598
7 Bioacoustic Native - (Linguistic Non-native) -1.749 -2.969 -0.511
8 Bioacoustic Native - (Bioacoustic Non-native) -2.057 -3.273 -0.818
9 Bioacoustic Native - (Combined Non-native) -1.834 -3.022 -0.563
10 Combined Native - (Linguistic Non-native) -1.894 -3.063 -0.626
11 Combined Native - (Bioacoustic Non-native) -2.202 -3.379 -0.937
12 Combined Native - (Combined Non-native) -1.978 -3.195 -0.746

2.2 Recall

Code
dat_day_1$condition_f <- factor(as.character(dat_day_1$Condition))
dat_day_1$ID <- factor(as.character(dat_day_1$ID))

levels(dat_day_1$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_1$L1_f <- factor(as.character(dat_day_1$L1))

levels(dat_day_1$L1_f) <- c("Native", "Non-native")

dat_day_1$vocab_sc <- scale(dat_day_1$vocab)

priors <- c(prior(normal(0, 4), class = "b"))
priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_recall <- brm(formula = Recall ~ condition_f * L1_f + vocab_sc + (1 | ID) + (1 | nonword), family = bernoulli(), iter = 5000, chains = chains, cores = chains, data = dat_day_1, backend = "cmdstanr", file = "./data/processed/regression_model_day_1_recall", prior = priors)
Code
mod_recall <- readRDS("./data/processed/regression_model_day_1_recall.rds")

extended_summary(fit = mod_recall, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) Recall ~ condition_f * L1_f + vocab_sc + (1 | ID) + (1 | nonword) 5000 4 1 2500 0 (0%) 0 289.283 528.92 1757220464
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_condition_fBioacoustic -0.361 -0.502 -0.218 1.001 1862.814 3950.725
b_condition_fCombined -0.184 -0.323 -0.038 1.001 1913.387 3727.522
b_L1_fNonMnative 1.076 0.149 1.984 1.023 289.283 783.856
b_vocab_sc 0.428 -0.061 0.914 1.012 318.872 528.920
b_condition_fBioacoustic:L1_fNonMnative 0.006 -0.192 0.207 1.001 1818.056 4162.768
b_condition_fCombined:L1_fNonMnative 0.399 0.198 0.600 1.001 1971.646 3701.597

2.2.1 Contrasts

2.2.1.1 Full table

Code
constrasts_recall <- as.data.frame(emmeans(mod_recall, pairwise ~
    condition_f * L1_f)$contrasts)

names(constrasts_recall)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(constrasts_recall[, 1:4], highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic Native - Bioacoustic Native 0.361 0.228 0.511
2 Linguistic Native - Combined Native 0.185 0.039 0.324
3 Linguistic Native - (Linguistic Non-native) -1.092 -1.970 -0.139
4 Linguistic Native - (Bioacoustic Non-native) -0.734 -1.603 0.219
5 Linguistic Native - (Combined Non-native) -1.300 -2.196 -0.347
6 Bioacoustic Native - Combined Native -0.177 -0.323 -0.036
7 Bioacoustic Native - (Linguistic Non-native) -1.444 -2.344 -0.500
8 Bioacoustic Native - (Bioacoustic Non-native) -1.090 -2.028 -0.177
9 Bioacoustic Native - (Combined Non-native) -1.655 -2.563 -0.706
10 Combined Native - (Linguistic Non-native) -1.268 -2.142 -0.301
11 Combined Native - (Bioacoustic Non-native) -0.910 -1.786 0.060
12 Combined Native - (Combined Non-native) -1.480 -2.385 -0.525
13 (Linguistic Non-native) - (Bioacoustic Non-native) 0.355 0.221 0.497
14 (Linguistic Non-native) - (Combined Non-native) -0.216 -0.349 -0.075
15 (Bioacoustic Non-native) - (Combined Non-native) -0.569 -0.711 -0.431

2.2.1.2 Subset native vs non-native

Code
constrasts_recall$first <- sapply(strsplit(constrasts_recall$contrast,
    " - "), "[[", 1)
constrasts_recall$second <- sapply(strsplit(constrasts_recall$contrast,
    " - "), "[[", 2)

constrasts_recall <- constrasts_recall[!grepl("Non-native", constrasts_recall$first) &
    grepl("Non-native", constrasts_recall$second), ]

coef_table <- html_format_coef_table(constrasts_recall[, 1:4], highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
3 Linguistic Native - (Linguistic Non-native) -1.092 -1.970 -0.139
4 Linguistic Native - (Bioacoustic Non-native) -0.734 -1.603 0.219
5 Linguistic Native - (Combined Non-native) -1.300 -2.196 -0.347
7 Bioacoustic Native - (Linguistic Non-native) -1.444 -2.344 -0.500
8 Bioacoustic Native - (Bioacoustic Non-native) -1.090 -2.028 -0.177
9 Bioacoustic Native - (Combined Non-native) -1.655 -2.563 -0.706
10 Combined Native - (Linguistic Non-native) -1.268 -2.142 -0.301
11 Combined Native - (Bioacoustic Non-native) -0.910 -1.786 0.060
12 Combined Native - (Combined Non-native) -1.480 -2.385 -0.525

2.3 LDT

2.3.1 Day 2

Code
## Offline
dat_day_2_ldt_accu$condition_f <- factor(as.character(dat_day_2_ldt_accu$Condition))
dat_day_2_ldt_accu$ID <- factor(as.character(dat_day_2_ldt_accu$ID))

levels(dat_day_2_ldt_accu$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_2_ldt_accu$L1_f <- factor(as.character(dat_day_2_ldt_accu$L1))

levels(dat_day_2_ldt_accu$L1_f) <- c("Native", "Non-native")

dat_day_2_ldt_accu$vocab_sc <- scale(dat_day_2_ldt_accu$Vocab)

dat_day_2_ldt_accu$recall_f <- factor(as.character(dat_day_2_ldt_accu$Recall))

dat_day_2_ldt_accu$relate_f <- factor(as.character(dat_day_2_ldt_accu$Relate))
levels(dat_day_2_ldt_accu$relate_f) <- c("Related", "Unrelated", "Nonword")


priors <- c(prior(normal(0, 4), class = "b"))
priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_accu_ldt <- brm(formula = Accuracy ~ condition_f * L1_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime), family = bernoulli(), iter = 5000, chains = chains, cores = chains, data = dat_day_2_ldt_accu, backend = "cmdstanr", file = "./data/processed/regression_model_day_2_LDT_offline_accuracy", prior = priors)


## Online

dat_day_2_online$condition_f <- factor(as.character(dat_day_2_online$Condition))
levels(dat_day_2_online$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_2_online$relate_f <- factor(as.character(dat_day_2_online$Relate))
levels(dat_day_2_online$relate_f) <- c("Related", "Unrelated", "Nonword")

dat_day_2_online$ID <- factor(as.character(dat_day_2_online$ID))

dat_day_2_online$L1_f <- factor(as.character(dat_day_2_online$L1))

levels(dat_day_2_online$L1_f) <- c("Native", "Non-native")

dat_day_2_online$vocab_sc <- scale(dat_day_2_online$Vocab)

dat_day_2_online$recall_f <- factor(as.character(dat_day_2_online$Recall))

levels(dat_day_2_online$recall_f) <- c("No", "Yes")

priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_LDT <- brm(formula = RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f +(1 | ID) + (1 | prime), family = lognormal(), iter = 5000, chains = chains, cores = chains, data = dat_day_2_online, backend = "cmdstanr", file = "./data/processed/regression_model_day_2_LDT", prior = priors)

2.3.1.1 Offline

Code
mod_LDT_accuracy <- readRDS("./data/processed/regression_model_day_2_LDT_offline_accuracy.rds")

extended_summary(fit = mod_LDT_accuracy, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) Accuracy ~ condition_f * L1_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime) 5000 4 1 2500 0 (0%) 0 3070.534 4979.227 2137380720
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_condition_fBioacoustic -0.169 -0.644 0.293 1 6376.692 6847.107
b_condition_fCombined -0.300 -0.762 0.151 1 6252.080 7207.160
b_L1_fNonMnative -0.069 -0.686 0.560 1 4042.662 5712.820
b_vocab_sc 0.503 0.241 0.774 1.001 3070.534 4979.227
b_relate_fUnrelated 0.560 0.033 1.076 1 9410.248 7262.253
b_relate_fNonword -1.643 -2.029 -1.282 1 9716.942 7310.181
b_recall_f1 -0.029 -0.301 0.238 1 10072.274 7642.135
b_condition_fBioacoustic:L1_fNonMnative 0.137 -0.439 0.721 1.001 5674.102 6859.627
b_condition_fCombined:L1_fNonMnative 0.337 -0.229 0.903 1.001 5978.808 6839.564

2.3.1.1.1 Contrasts
Code
contrasts_LDT_acc <- as.data.frame(emmeans(mod_LDT_accuracy, pairwise ~
    condition_f)$contrasts)

names(contrasts_LDT_acc)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_LDT_acc, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic - Bioacoustic 0.099 -0.194 0.394
2 Linguistic - Combined 0.130 -0.156 0.414
3 Bioacoustic - Combined 0.031 -0.246 0.308

2.3.1.2 Online

Code
mod_LDT <- readRDS("./data/processed/regression_model_day_2_LDT.rds")

extended_summary(fit = mod_LDT, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) sigma-student_t(3, 0, 2.5) RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime) 5000 4 1 2500 0 (0%) 0 1511.687 2472.86 1037028722
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_L1_fNonMnative 0.269 0.173 0.363 1.002 1511.687 2472.860
b_condition_fBioacoustic -0.009 -0.030 0.011 1 11342.691 7630.304
b_condition_fCombined 0.013 -0.008 0.034 1 11450.319 8184.555
b_vocab_sc -0.006 -0.049 0.039 1.004 1596.437 2848.910
b_relate_fUnrelated 0.041 0.017 0.065 1 10112.424 7841.678
b_relate_fNonword 0.262 0.241 0.283 1.001 9948.200 7809.073
b_recall_fYes -0.010 -0.031 0.011 1 9188.299 7571.473

2.3.1.2.1 Contrasts
Code
contrasts_LDT <- as.data.frame(emmeans(mod_LDT, pairwise ~ condition_f)$contrasts)

names(contrasts_LDT)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_LDT, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic - Bioacoustic 0.010 -0.012 0.029
2 Linguistic - Combined -0.013 -0.033 0.008
3 Bioacoustic - Combined -0.022 -0.044 -0.001

2.3.2 Day 3

Code
str(dat_day_3_online)

dat_day_3_online$condition_f <- factor(as.character(dat_day_3_online$Condition))
levels(dat_day_3_online$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_3_online$relate_f <- factor(as.character(dat_day_3_online$Relate))
levels(dat_day_3_online$relate_f) <- c("Related", "Unrelated", "Nonword")

dat_day_3_online$ID <- factor(as.character(dat_day_3_online$ID))

dat_day_3_online$L1_f <- factor(as.character(dat_day_3_online$L1))

levels(dat_day_3_online$L1_f) <- c("Native", "Non-native")

dat_day_3_online$vocab_sc <- scale(dat_day_3_online$Vocab)

dat_day_3_online$recall_f <- factor(as.character(dat_day_3_online$Recall))

levels(dat_day_3_online$recall_f) <- c("No", "Yes")


priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_LDT <- brm(formula = RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f +(1 | ID) + (1 | prime), family = lognormal(), iter = 5000, chains = chains, cores = chains, data = dat_day_3_online, backend = "cmdstanr", file = "./data/processed/regression_model_day_3_LDT", prior = priors)
Code
mod_LDT <- readRDS("./data/processed/regression_model_day_3_LDT.rds")

extended_summary(fit = mod_LDT, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) sigma-student_t(3, 0, 2.5) RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime) 5000 4 1 2500 0 (0%) 0 1958.184 3249.77 83276395
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_L1_fNonMnative 0.202 0.090 0.317 1.001 2280.989 3724.648
b_condition_fBioacoustic 0.044 -0.082 0.169 1.002 1987.261 3249.770
b_condition_fCombined -0.106 -0.236 0.024 1.003 1958.184 3659.207
b_vocab_sc -0.032 -0.087 0.023 1.001 2883.621 4086.469
b_relate_fUnrelated 0.013 -0.016 0.041 1.001 8732.392 6831.241
b_relate_fNonword 0.240 0.215 0.265 1 9052.062 7724.233
b_recall_fYes 0.011 -0.011 0.034 1 9812.092 7710.282

2.3.2.1 Contrasts

Code
contrasts_LDT <- as.data.frame(emmeans(mod_LDT, pairwise ~ condition_f)$contrasts)

names(contrasts_LDT)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_LDT, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic - Bioacoustic -0.043 -0.165 0.086
2 Linguistic - Combined 0.106 -0.025 0.233
3 Bioacoustic - Combined 0.150 0.027 0.273

2.4 PLDT

2.4.1 Day 2

Code
## Offline

dat_day_2_pldt_accu$condition_f <- factor(as.character(dat_day_2_pldt_accu$Condition))
dat_day_2_pldt_accu$ID <- factor(as.character(dat_day_2_pldt_accu$ID))

levels(dat_day_2_pldt_accu$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_2_pldt_accu$L1_f <- factor(as.character(dat_day_2_pldt_accu$L1))

levels(dat_day_2_pldt_accu$L1_f) <- c("Native", "Non-native")

dat_day_2_pldt_accu$vocab_sc <- scale(dat_day_2_pldt_accu$Vocab)

dat_day_2_pldt_accu$recall_f <- factor(as.character(dat_day_2_pldt_accu$Recall))

dat_day_2_pldt_accu$relate_f <- factor(as.character(dat_day_2_pldt_accu$Related))
levels(dat_day_2_pldt_accu$relate_f) <- c("Related", "Unrelated", "Nonword")


priors <- c(prior(normal(0, 4), class = "b"))
priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_accu_pldt <- brm(formula = Accu ~ condition_f * L1_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime), family = bernoulli(), iter = 5000, chains = chains, cores = chains, data = dat_day_2_pldt_accu, backend = "cmdstanr", file = "./data/processed/regression_model_day_2_PLDT_offline_accuracy", prior = priors)


## Online

dat_day_2_pldt$condition_f <- factor(as.character(dat_day_2_pldt$Condition))
levels(dat_day_2_pldt$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_2_pldt$relate_f <- factor(as.character(dat_day_2_pldt$Related))
levels(dat_day_2_pldt$relate_f) <- c("Related", "Unrelated", "Nonword")

dat_day_2_pldt$ID <- factor(as.character(dat_day_2_pldt$ID))

dat_day_2_pldt$L1_f <- factor(as.character(dat_day_2_pldt$L1))

levels(dat_day_2_pldt$L1_f) <- c("Native", "Non-native")

dat_day_2_pldt$vocab_sc <- scale(dat_day_2_pldt$Vocab)

dat_day_2_pldt$recall_f <- factor(as.character(dat_day_2_pldt$Recall))

levels(dat_day_2_pldt$recall_f) <- c("No", "Yes")

priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_PLDT2 <- brm(formula = RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f +(1 | ID) + (1 | prime), family = lognormal(), iter = 5000, chains = chains, cores = chains, data = dat_day_2_pldt, backend = "cmdstanr", file = "./data/processed/regression_model_day_2_PLDT_online", prior = priors)

2.4.1.1 Offline

Code
mod_accu_pldt <- readRDS("./data/processed/regression_model_day_2_PLDT_offline_accuracy.rds")

extended_summary(fit = mod_accu_pldt, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) Accu ~ condition_f * L1_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime) 5000 4 1 2500 0 (0%) 0 2003.045 3678.911 809429635
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_condition_fBioacoustic 0.025 -0.268 0.322 1 5613.485 6698.451
b_condition_fCombined -0.075 -0.349 0.195 1 5727.521 7075.622
b_L1_fNonMnative -0.194 -0.634 0.244 1.001 2003.045 4191.296
b_vocab_sc 0.188 -0.010 0.382 1 2045.280 3678.911
b_relate_fUnrelated 0.075 -0.083 0.234 1 10257.887 8089.596
b_relate_fNonword 0.276 0.111 0.437 1 10476.306 7903.654
b_recall_f1 -0.005 -0.165 0.155 1 9611.209 8056.877
b_condition_fBioacoustic:L1_fNonMnative 0.002 -0.357 0.357 1 5921.549 6962.604
b_condition_fCombined:L1_fNonMnative 0.109 -0.222 0.445 1 5979.141 7110.789

2.4.1.1.1 Contrasts
Code
contrasts_PLDT <- as.data.frame(emmeans(mod_accu_pldt, pairwise ~
    condition_f)$contrasts)

names(contrasts_PLDT)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_PLDT, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic - Bioacoustic -0.026 -0.231 0.172
2 Linguistic - Combined 0.020 -0.167 0.194
3 Bioacoustic - Combined 0.047 -0.168 0.260

2.4.1.2 Online

Code
mod_PLDT2 <- readRDS("./data/processed/regression_model_day_2_PLDT_online.rds")

extended_summary(fit = mod_PLDT2, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) sigma-student_t(3, 0, 2.5) RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime) 5000 4 1 2500 0 (0%) 0 1751.544 3368.958 463403340
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_L1_fNonMnative 0.407 0.207 0.604 1.002 1751.544 3756.577
b_condition_fBioacoustic -0.012 -0.066 0.042 1 13472.997 7601.574
b_condition_fCombined 0.029 -0.019 0.076 1 16371.390 8478.013
b_vocab_sc 0.012 -0.091 0.114 1.001 1954.469 3368.958
b_relate_fUnrelated -0.270 -0.319 -0.221 1 14376.894 8182.919
b_relate_fNonword -0.282 -0.330 -0.233 1.001 14274.979 8021.660
b_recall_fYes 0.059 0.012 0.107 1.001 15717.337 7956.028

2.4.1.2.1 Contrasts
Code
contrasts_PLDT <- as.data.frame(emmeans(mod_PLDT2, pairwise ~ condition_f)$contrasts)

names(contrasts_PLDT)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_PLDT, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic - Bioacoustic 0.011 -0.042 0.066
2 Linguistic - Combined -0.029 -0.076 0.018
3 Bioacoustic - Combined -0.041 -0.096 0.015

2.4.2 Day 3

Code
str(dat_day_3_pldt)

dat_day_3_pldt$condition_f <- factor(as.character(dat_day_3_pldt$Condition))
levels(dat_day_3_pldt$condition_f) <- c("Linguistic", "Bioacoustic", "Combined")

dat_day_3_pldt$relate_f <- factor(as.character(dat_day_3_pldt$Relate))
levels(dat_day_3_pldt$relate_f) <- c("Related", "Unrelated", "Nonword")

dat_day_3_pldt$ID <- factor(as.character(dat_day_3_pldt$ID))

dat_day_3_pldt$L1_f <- factor(as.character(dat_day_3_pldt$L1))

levels(dat_day_3_pldt$L1_f) <- c("Native", "Non-native")

dat_day_3_pldt$vocab_sc <- scale(dat_day_3_pldt$VocabularyTest)

dat_day_3_pldt$recall_f <- factor(as.character(dat_day_3_pldt$Recall))

levels(dat_day_3_pldt$recall_f) <- c("No", "Yes")


priors <- c(
  # Prior for the intercept
  prior(normal(0, 10), class = Intercept),
  
  # Priors for the regression coefficients
  prior(normal(0, 2.5), class = b),
  
  # Prior for the group-level standard deviations (if applicable)
  prior(exponential(1), class = sd)
)

chains  <- 4 

mod_LDT <- brm(formula = RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f +(1 | ID) + (1 | prime), family = lognormal(), iter = 5000, chains = chains, cores = chains, data = dat_day_3_pldt, backend = "cmdstanr", file = "./data/processed/regression_model_day_3_PLDT", prior = priors)
Code
mod_PLDT3 <- readRDS("./data/processed/regression_model_day_3_PLDT.rds")

extended_summary(fit = mod_PLDT3, highlight = TRUE, remove.intercepts = TRUE,
    print.name = FALSE, fill = viridis(10)[8])
priors formula iterations chains thinning warmup diverg_transitions rhats > 1.05 min_bulk_ESS min_tail_ESS seed
1 b-normal(0, 2.5) Intercept-normal(0, 10) sd-exponential(1) sigma-student_t(3, 0, 2.5) RT ~ L1_f + condition_f + vocab_sc + relate_f + recall_f + (1 | ID) + (1 | prime) 5000 4 1 2500 0 (0%) 0 2042.6 3871.694 1693146355
Estimate l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
b_L1_fNonMnative 0.364 0.161 0.565 1.002 2602.473 3945.125
b_condition_fBioacoustic 0.059 -0.159 0.278 1.001 2042.600 3871.694
b_condition_fCombined -0.037 -0.267 0.191 1.001 2466.030 4196.226
b_vocab_sc -0.005 -0.097 0.092 1.001 3103.302 5082.548
b_relate_fUnrelated -0.269 -0.323 -0.215 1 14405.496 8120.520
b_relate_fNonword -0.285 -0.340 -0.230 1 13960.872 8529.537
b_recall_fYes -0.030 -0.081 0.023 1.001 16624.182 7043.095

2.4.2.1 Contrasts

Code
contrasts_PLDT3 <- as.data.frame(emmeans(mod_PLDT3, pairwise ~ condition_f)$contrasts)

names(contrasts_PLDT3)[3:4] <- c("l-95% CI", "u-95% CI")

coef_table <- html_format_coef_table(contrasts_PLDT3, highlight = TRUE,
    fill = viridis(10)[8])

print(coef_table)
contrast estimate l-95% CI u-95% CI
1 Linguistic - Bioacoustic -0.057 -0.271 0.166
2 Linguistic - Combined 0.035 -0.192 0.265
3 Bioacoustic - Combined 0.097 -0.121 0.322

Takeaways

 


 

Session information

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=es_CR.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=es_CR.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=es_CR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=es_CR.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Costa_Rica
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] viridis_0.6.5     viridisLite_0.4.2 emmeans_1.10.3    brms_2.21.0      
 [5] Rcpp_1.0.13       Hmisc_5.1-3       readxl_1.4.3      corrplot_0.92    
 [9] sjPlot_2.8.16     psych_2.4.6.26    lme4_1.1-35.5     Matrix_1.7-0     

loaded via a namespace (and not attached):
  [1] mnormt_2.1.1         gridExtra_2.3        formatR_1.14        
  [4] remotes_2.5.0        inline_0.3.19        sandwich_3.1-0      
  [7] rlang_1.1.4          magrittr_2.0.3       multcomp_1.4-25     
 [10] matrixStats_1.3.0    compiler_4.4.1       loo_2.7.0           
 [13] systemfonts_1.1.0    reshape2_1.4.4       vctrs_0.6.5         
 [16] stringr_1.5.1        pkgconfig_2.0.3      crayon_1.5.3        
 [19] fastmap_1.2.0        backports_1.5.0      labeling_0.4.3      
 [22] utf8_1.2.4           cmdstanr_0.8.1.9000  rmarkdown_2.27      
 [25] ps_1.7.7             nloptr_2.1.1         purrr_1.0.2         
 [28] xfun_0.46            jsonlite_1.8.8       sjmisc_2.8.10       
 [31] ggeffects_1.7.0      parallel_4.4.1       cluster_2.1.6       
 [34] R6_2.5.1             stringi_1.8.4        StanHeaders_2.32.9  
 [37] boot_1.3-30          rpart_4.1.23         cellranger_1.1.0    
 [40] estimability_1.5.1   rstan_2.32.6         knitr_1.48          
 [43] zoo_1.8-12           base64enc_0.1-3      bayesplot_1.11.1    
 [46] splines_4.4.1        nnet_7.3-19          tidyselect_1.2.1    
 [49] rstudioapi_0.16.0    abind_1.4-5          yaml_2.3.9          
 [52] codetools_0.2-20     sjlabelled_1.2.0     processx_3.8.4      
 [55] curl_5.2.1           pkgbuild_1.4.4       plyr_1.8.9          
 [58] lattice_0.22-6       tibble_3.2.1         withr_3.0.0         
 [61] bridgesampling_1.1-2 posterior_1.6.0      coda_0.19-4.1       
 [64] evaluate_0.24.0      foreign_0.8-87       survival_3.7-0      
 [67] sketchy_1.0.3        RcppParallel_5.1.7   xml2_1.3.6          
 [70] ggdist_3.3.2         pillar_1.9.0         tensorA_0.36.2.1    
 [73] packrat_0.9.2        checkmate_2.3.1      stats4_4.4.1        
 [76] insight_0.20.2       distributional_0.4.0 generics_0.1.3      
 [79] ggplot2_3.5.1        rstantools_2.4.0     munsell_0.5.1       
 [82] scales_1.3.0         minqa_1.2.7          xtable_1.8-4        
 [85] glue_1.7.0           tools_4.4.1          xaringanExtra_0.8.0 
 [88] data.table_1.15.4    mvtnorm_1.2-5        cowplot_1.1.3       
 [91] grid_4.4.1           tidyr_1.3.1          QuickJSR_1.2.2      
 [94] datawizard_0.12.1    colorspace_2.1-0     nlme_3.1-165        
 [97] performance_0.12.2   htmlTable_2.4.2      Formula_1.2-5       
[100] cli_3.6.3            kableExtra_1.4.0     fansi_1.0.6         
[103] svglite_2.1.3        Brobdingnag_1.2-9    sjstats_0.19.0      
[106] dplyr_1.1.4          V8_4.4.2             gtable_0.3.5        
[109] digest_0.6.36        TH.data_1.1-2        farver_2.1.2        
[112] htmlwidgets_1.6.4    htmltools_0.5.8.1    lifecycle_1.0.4     
[115] MASS_7.3-61