OSCR

The neural dynamics of political socio-pragmatic violations: an ERP study.

Code ↔ Paper

2 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 2 matches
  1. [1] § Materials and methods › Statistical analysis › ERP analysis ↔ polpejEEG_repo.R, lines 143 to 181 · score 0.69 · Bonferroni Holm, NoQM, lme4, bobyqa, optimizer, IC · Report a mismatch
  2. [2] § Materials and methods › Statistical analysis › Lexeme characteristics and SDO ↔ polpejEEG_repo.R, lines 143 to 181 · score 0.65 · Bonferroni Holm, NoQM, Word frequencies, syllables, position, channel · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R · 627 lines · 22 KB · no license · 2 matches

  1. library(lme4)
  2. library(glmmTMB)
  3. library(emmeans)
  4. library(ggplot2)
  5. library(sjPlot)
  6. library(lmerTest)
  7. library(lattice)
  8. library(rlist)
  9. library(DHARMa)
  10. library(ggsignif)
  11. library(stringr)
  12. library(dplyr)
  13. library(tidyr)
  14. library(ggeffects)
  15. library(sjstats)
  16. library(ggpubr)
  17. library(effectsize)
  18. # set working directory
  19. setwd("C:/Users/maure/Desktop/PolPejEEG/Export")
  20. # read ERP data
  21. N400_df <- read.csv("./csvs/N400_df.csv")
  22. P300_df <- read.csv("./csvs/P300_df.csv")
  23. LPP_df <- read.csv("./csvs/LPP_df.csv")
  24. # set lmem and notational options
  25. emm_options(pbkrtest.limit = 3000)
  26. options(scipen=999)
  27. # bring dfs into long format and drop rows containing nans
  28. N400_df_long <- pivot_longer(N400_df, c("Cz", "Pz"), names_to = "Channel", values_to = "Amplitude")
  29. N400_df_long <- drop_na(N400_df_long, "Pej.Value")
  30. N400_df_long <- rename(N400_df_long, Amplitude_N400=Amplitude)
  31. n_df <- N400_df_long %>%
  32. filter(Channel=="Cz") %>%
  33. group_by(Participant, Coherence, Quotation) %>%
  34. count()
  35. n_df[n_df$n < 15, ]
  36. length(unique(N400_df$Participant))
  37. length(unique(N400_df_long$Participant))
  38. P300_df_long <- pivot_longer(P300_df, c("Cz", "Pz"), names_to = "Channel", values_to = "Amplitude")
  39. P300_df_long <- drop_na(P300_df_long, "Pej.Value")
  40. P300_df_long <- rename(P300_df_long, Amplitude_P300=Amplitude)
  41. LPP_df_long <- pivot_longer(LPP_df, c("P3", "Pz", "P4"), names_to = "Channel", values_to = "Amplitude")
  42. LPP_df_long <- drop_na(LPP_df_long)
  43. LPP_df_long <- rename(LPP_df_long, Amplitude_LPP=Amplitude)
  44. Amplitude_P300 <- P300_df_long$Amplitude_P300
  45. Amplitude_LPP <- LPP_df_long$Amplitude_LPP
  46. # bind dfs
  47. df_long <- cbind(N400_df_long, Amplitude_P300)
  48. # scale and center numerical variables
  49. df_long$Pej.Value <- scale(df_long$Pej.Value, center=T)
  50. df_long$Amplitude_N400_unscaled <- df_long$Amplitude_N400
  51. df_long$Amplitude_N400 <- scale(df_long$Amplitude_N400, center=T)
  52. df_long$Amplitude_P300_unscaled <- df_long$Amplitude_P300
  53. df_long$Amplitude_P300 <- scale(df_long$Amplitude_P300, center=T)
  54. df_long$SDO_mean <- scale(df_long$SDO_mean, center=T)
  55. LPP_df_long$Amplitude_LPP_unscaled <- LPP_df_long$Amplitude_LPP
  56. LPP_df_long$Amplitude_LPP <- scale(LPP_df_long$Amplitude_LPP, center=T)
  57. LPP_df_long$Pej.Value <- scale(LPP_df_long$Pej.Value, center=T)
  58. # factorize categorical variables
  59. df_long$Coherence <- as.factor(df_long$Coherence)
  60. df_long$Quotation <- as.factor(df_long$Quotation)
  61. LPP_df_long$Coherence <- as.factor(LPP_df_long$Coherence)
  62. LPP_df_long$Quotation <- as.factor(LPP_df_long$Quotation)
  63. # perform effect coding
  64. contrasts(df_long$Coherence) <- "contr.sum"
  65. contrasts(df_long$Quotation) <- "contr.sum"
  66. contrasts(LPP_df_long$Coherence) <- "contr.sum"
  67. contrasts(LPP_df_long$Quotation) <- "contr.sum"
  68. ## extract and save raw amplitude parameters
  69. m_sd_N400 <- df_long %>% drop_na() %>% group_by(Coherence, Quotation, Channel) %>%
  70. summarize(mean_amplitude = mean
  71. (Amplitude_N400_unscaled), sd_amplitude = sd(Amplitude_N400_unscaled))
  72. m_sd_P300 <- df_long %>% drop_na() %>% group_by(Coherence, Quotation, Channel) %>%
  73. summarize(mean_amplitude = mean
  74. (Amplitude_P300_unscaled), sd_amplitude = sd(Amplitude_P300_unscaled))
  75. m_sd_LPP <- LPP_df_long %>% drop_na() %>% group_by(Coherence, Quotation, Channel) %>%
  76. summarize(mean_amplitude = mean
  77. (Amplitude_LPP_unscaled), sd_amplitude = sd(Amplitude_LPP_unscaled))
  78. m_sd_df <- as.data.frame(rbind(m_sd_N400, m_sd_P300, m_sd_LPP))
  79. write.csv(m_sd_df, file="./csvs/m_sd_df.csv")
  80. df_long_1ch <- df_long %>% filter(Channel == "Cz")
  81. word_df <- read.csv("./word_data/word_frequencies_dwds_gegenwartskorpus.csv")
  82. word_df_clean <- word_df[word_df$AmbigUsage!="Y",]
  83. df_word_freq <- merge(df_long_1ch, word_df[, -3], by="Word")
  84. contrasts(df_word_freq$Coherence) <- "contr.treatment"
  85. df_word_freq_clean <- df_word_freq %>% filter(AmbigUsage!="Y")
  86. df_word_freq_clean$logWordsFrequencyPerMillion <- log(df_word_freq_clean$WordsFrequencyPerMillion+1)
  87. df_word_freq_clean %>% group_by(Coherence) %>%
  88. summarize(M = mean(WordsFrequencyPerMillion),
  89. SD = sd(WordsFrequencyPerMillion),
  90. Median = median(WordsFrequencyPerMillion),
  91. logM = mean(logWordsFrequencyPerMillion),
  92. logSD = sd(logWordsFrequencyPerMillion),
  93. logMedian = median(logWordsFrequencyPerMillion))
  94. pej_df_word <- df_long_1ch %>% group_by(Word) %>%
  95. summarize(mean_pej = mean(Pej.Value))
  96. word_df <- left_join(word_df, pej_df_word, by="Word")
  97. word_df
  98. write.csv(word_df, file="./word_data/word_characteristics_supplementary.csv")
  99. C_clean <- word_df_clean[word_df_clean$Coherence=="C",]
  100. IC_clean <- word_df_clean[word_df_clean$Coherence=="IC",]
  101. C <- word_df[word_df$Coherence=="C",]
  102. IC <- word_df[word_df$Coherence=="IC",]
  103. # t-tests of potential covariates
  104. t1 <- t.test(C_clean$WordsFrequencyPerMillion, IC_clean$WordsFrequencyPerMillion)
  105. t1
  106. sd(C_clean$WordsFrequencyPerMillion)
  107. sd(IC_clean$WordsFrequencyPerMillion)
  108. t2 <- t.test(C$n_Letters, IC$n_Letters)
  109. t2
  110. sd(C$n_Letters)
  111. sd(IC$n_Letters)
  112. t3 <- t.test(C$n_Syllables, IC$n_Syllables)
  113. t3
  114. sd(C$n_Syllables)
  115. sd(IC$n_Syllables)
  116. t4 <- t.test(C$TargetPosition, IC$TargetPosition)
  117. t4
  118. sd(C$TargetPosition)
  119. sd(IC$TargetPosition)
  120. t5 <- t.test(C$mean_pej, IC$mean_pej)
  121. t5
  122. sd(C$mean_pej)
  123. sd(IC$mean_pej)
  124. p_list <- sort(c(t1$p.value, t2$p.value, t3$p.value, t4$p.value, t5$p.value))
  125. p_list*c(5, 4, 3, 2, 1) #bonferroni-holm correction
  126. word_df_syl <- word_df %>% select(c(Word, n_Syllables))
  127. df_long <- merge(df_long, word_df_syl, by="Word")
  128. df_long_NoQM <- df_long %>% filter(Quotation=="NoQM")
  129. # build model based on n_syllables to show assess the isolated potential effect of the number of syllables
  130. syl_model <- lmer(Amplitude_N400 ~ n_Syllables + (1+n_Syllables|Participant) + (1|Word) + (1|Channel),
  131. data=df_long_NoQM, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  132. summary(syl_model)
  133. # building the models usually takes a lot of time and resources
  134. # models objects are therefore provided as .rda files and can be loaded
  135. # N400 amplitude analysis
  136. #model_full <- lmer(Amplitude_N400 ~ Coherence*Quotation*Pej.Value + (1 + Coherence*Quotation*Pej.Value|Participant) + (1 + Quotation*Pej.Value|Word) + (1 + Coherence*Quotation*Pej.Value|Channel),
  137. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  138. #save(model_full, file="N400_model_full.rda")
  139. #load("N400_model_full.rda")
  140. #summary(model_full)
  141. #model_nochslopes <- lmer(Amplitude_N400 ~ Coherence*Quotation*Pej.Value + (1 + Coherence*Quotation*Pej.Value||Participant) + (1 + Quotation*Pej.Value||Word) + (1|Channel),
  142. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  143. #save(model_nochslopes, file="N400_model_nochslopes.rda")
  144. #load("N400_model_nochslopes.rda")
  145. #summary(model_nochslopes)
  146. #model_inter_nochslopes <- lmer(Amplitude_N400 ~ Coherence*Quotation*Pej.Value + (1 + Coherence:Quotation:Pej.Value|Participant) + (1 + Quotation:Pej.Value|Word) + (1|Channel),
  147. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  148. #save(model_inter_nochslopes, file="N400_model_inter_nochslopes.rda")
  149. #load("N400_model_inter_nochslopes.rda")
  150. #summary(model_inter_nochslopes)
  151. #model_inter_nochslopes_nocorr <- lmer(Amplitude_N400 ~ Coherence*Quotation*Pej.Value + (1 + Coherence:Quotation:Pej.Value||Participant) + (1 + Quotation:Pej.Value||Word) + (1|Channel),
  152. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  153. #save(model_inter_nochslopes_nocorr, file="N400_model_inter_nochslopes_nocorr.rda")
  154. #load("N400_model_inter_nochslopes_nocorr.rda")
  155. #summary(model_inter_nochslopes_nocorr)
  156. #model <- model_inter_nochslopes_nocorr
  157. #save(model, file="N400_model.rda")
  158. model_SDO_re <- lmer(Amplitude_N400 ~ Coherence*Quotation*Pej.Value + (1 + Coherence:Quotation:Pej.Value||SDO_mean) + (1 + Quotation:Pej.Value||Word) + (1|Channel),
  159. data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  160. save(model_SDO_re, file="N400_model_SDO_re.rda")
  161. load("N400_model_SDO_re.rda")
  162. model_SDO_sum <- summary(model_SDO_re)
  163. print(model_SDO_sum)
  164. write.csv(model_SDO_sum$coefficients, "./csvs/combined_model_SDO_summary_N400.csv") # write summary to file
  165. model_SDO <- lmer(Amplitude_N400 ~ Coherence*Quotation*Pej.Value*SDO_mean + (1 + Coherence:Quotation:Pej.Value:SDO_mean||Participant) + (1 + Quotation:Pej.Value:SDO_mean||Word) + (1|Channel),
  166. data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  167. save(model_SDO, file="N400_model_SDO.rda")
  168. summary(model_SDO)
  169. ## load model
  170. load("N400_model.rda")
  171. anova(model_SDO_re, model)
  172. ## lmem summary
  173. model_sum <- summary(model)
  174. print(model_sum)
  175. write.csv(model_sum$coefficients, "./csvs/combined_model_summary_N400.csv") # write summary to file
  176. ## estimated marginal means
  177. emm_means <- emmeans(model, ~ Coherence*Quotation) # define estimated marginal means formula
  178. emm_means
  179. emm_contrasts <- contrast(emm_means, list(c(1, -1, 0, 0), c(0, 0, 1, -1), c(0, 1, 0, -1), c(1, 0, -1, 0)), adjust="holm") # define contrasts for emms
  180. emm_contrasts
  181. emm_means_df <- as.data.frame(emm_means)
  182. emm_contrasts_df <- as.data.frame(emm_contrasts) %>% mutate(contrast = str_replace_all(contrast, "C ", "C-"))
  183. #eta_squared(model, partial=TRUE)
  184. ## define plot variables
  185. means <- emm_means_df$emmean
  186. SEs <- emm_means_df$SE
  187. max_NoQM <- max((means+SEs)[1:2])
  188. max_QM <- max((means+SEs)[3:4])
  189. ## plot group differences
  190. QC_plot <- ggplot(emm_means_df, aes(x = Quotation, y = emmean, color = Coherence)) +
  191. ylim(-0.6, 0.6) +
  192. geom_point(position = position_dodge(width = 0.3), size=3) +
  193. geom_errorbar(aes(ymin = means-SEs, ymax = means+SEs),
  194. position = position_dodge(width = 0.3), # Shift error bars
  195. linewidth = 0.8, # Make error bars thicker
  196. width = 0.2) +
  197. labs(title = "",
  198. x = "Quotation",
  199. y = "N400 Amplitude (z-standardized)",
  200. color = "Coherence") +
  201. theme(text = element_text(size=14)) +
  202. geom_signif(y_position = c(max_QM+0.05, max_NoQM+0.05, max_NoQM+0.15, max_QM+0.15),
  203. xmin = c(1.925, 0.925, 0.925, 1.075),
  204. xmax = c(2.075, 1.075, 1.925, 2.075),
  205. annotation = c("*", "*", "n.s.", "***"),
  206. tip_length = 0, color="black") +
  207. scale_color_brewer(palette="Dark2") +
  208. theme(legend.position = "bottom")
  209. plot(QC_plot)
  210. ggsave("./plots/QC_plot_N400.png", dpi=300, width=1000, height=1200, units="px")
  211. ## plot three-way interaction
  212. all_plot <- plot_model(model, type="pred", terms=c("Pej.Value", "Coherence", "Quotation"), title="", axis.title=c("Pejorative Weight (z-standardized)", "N400 Amplitude (z-standardized)"), colors = "Dark2") +
  213. theme(legend.position = "bottom") + ylim(-0.6, 0.6)
  214. plot(all_plot)
  215. ggsave("./plots/all_plot_N400.png", dpi=300, width=2000, height=1200, units="px")
  216. ## plot model estimates
  217. est_plot <- plot_model(model, type="est", colors="Set1", title="", axis.lim = c(-0.25, 0.25),
  218. axis.labels = c("Coh * Quot * Pej.Weight", "Quotation * Pejorative Weight",
  219. "Coherence * Pejorative Weight", "Coherence * Quotation",
  220. "Pejorative Weight", "Quotation", "Coherence"
  221. )) + theme(axis.text.y = element_text(angle = 30)) +
  222. ylim(-0.25, 0.25)
  223. plot(est_plot)
  224. ggsave("./plots/est_plot_N400.png", dpi=300, width=1500, height=1800, units="px")
  225. ## combine plots
  226. combi_plot <- ggarrange(all_plot,
  227. ggarrange(QC_plot, est_plot, ncol=2, labels=c("B", "C")),
  228. nrow=2,
  229. labels="A")
  230. plot(combi_plot)
  231. ggsave("./plots/combi_plot_N400.png", dpi=300, width=2400, height=2400, units="px")
  232. ## Diagnostics plots
  233. sim_res <- simulateResiduals(fittedModel = model, plot = F)
  234. ### Normality of residuals
  235. plotQQunif(sim_res, testUniformity = F, testOutliers = F, testDispersion = F)
  236. ### Normality of random effects
  237. load("N400_model_inter_nochslopes.rda")
  238. diag <- plot_model(model_inter_nochslopes, type="diag")
  239. # model_inter_nochslopes is used because plot_model cannot produce
  240. # diagnostic plots for model equations contain the '||' operator
  241. plot(diag[[2]]$Participant)
  242. plot(diag[[2]]$Word)
  243. plot(diag[[2]]$Channel)
  244. ### Homoskedasticity
  245. plot(diag[[4]])
  246. ## P300
  247. ## build and save model
  248. #model_full <- lmer(Amplitude_P300 ~ Coherence*Quotation*Pej.Value + (1 + Coherence*Quotation*Pej.Value|Participant) + (1 + Quotation*Pej.Value|Word) + (1 + Coherence*Quotation*Pej.Value|Channel),
  249. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  250. #save(model_full, file="P300_model_full.rda")
  251. #load("P300_model_full.rda")
  252. #summary(model_full)
  253. #model_nochslopes <- lmer(Amplitude_P300 ~ Coherence*Quotation*Pej.Value + (1 + Coherence*Quotation*Pej.Value||Participant) + (1 + Quotation*Pej.Value||Word) + (1|Channel),
  254. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  255. #save(model_nochslopes, file="P300_model_nochslopes.rda")
  256. #load("P300_model_nochslopes.rda")
  257. #summary(model_nochslopes)
  258. #model_inter_nochslopes <- lmer(Amplitude_P300 ~ Coherence*Quotation*Pej.Value + (1 + Coherence:Quotation:Pej.Value|Participant) + (1 + Quotation:Pej.Value|Word) + (1|Channel),
  259. # data=df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  260. #save(model_inter_nochslopes, file="P300_model_inter_nochslopes.rda")
  261. #load("P300_model_inter_nochslopes.rda")
  262. #summary(model_inter_nochslopes)
  263. #model <- model_inter_nochslopes
  264. #save(model, file="P300_model.rda")
  265. ## load model
  266. load("P300_model.rda")
  267. ## model summary
  268. model_sum <- summary(model)
  269. print(model_sum)
  270. write.csv(model_sum$coefficients, "./csvs/combined_model_summary_P300.csv")
  271. ## estimated marginal means
  272. emmeans(model, pairwise ~ Quotation)
  273. emm_means <- emmeans(model, ~ Coherence*Quotation)
  274. emm_means
  275. emm_contrasts <- contrast(emm_means, list(c(1, -1, 0, 0), c(0, 0, 1, -1), c(0, 1, 0, -1), c(1, 0, -1, 0)), adjust="holm")
  276. emm_contrasts
  277. emm_means_df <- as.data.frame(emm_means)
  278. emm_contrasts_df <- as.data.frame(emm_contrasts) %>% mutate(contrast = str_replace_all(contrast, "C ", "C-"))
  279. #eta_squared(model, partial=TRUE)
  280. ## define plot variables
  281. means <- emm_means_df$emmean
  282. SEs <- emm_means_df$SE
  283. max_NoQM <- max((means+SEs)[1:2])
  284. max_QM <- max((means+SEs)[3:4])
  285. ## plot group differences
  286. QC_plot <- ggplot(emm_means_df, aes(x = Quotation, y = emmean, color = Coherence)) +
  287. ylim(-0.6, 0.6) +
  288. geom_point(position = position_dodge(width = 0.3), size=3) +
  289. geom_errorbar(aes(ymin = means-SEs, ymax = means+SEs),
  290. position = position_dodge(width = 0.3), # Shift error bars
  291. linewidth = 0.8, # Make error bars thicker
  292. width = 0.2) +
  293. labs(title = "",
  294. x = "Quotation",
  295. y = "P300 Amplitude (z-standardized)",
  296. color = "Coherence") +
  297. theme(text = element_text(size=14)) +
  298. geom_signif(y_position = c(max_QM+0.15),
  299. xmin = c(1),
  300. xmax = c(2),
  301. annotation = c("***"),
  302. tip_length = 0.1, color="black") +
  303. scale_color_brewer(palette="Dark2") +
  304. theme(legend.position = "bottom")
  305. plot(QC_plot)
  306. ggsave("./plots/QC_plot_P300.png", dpi=300, width=1000, height=1200, units="px")
  307. ## plot three-way interaction
  308. all_plot <- plot_model(model, type="pred", terms=c("Pej.Value", "Coherence", "Quotation"), title="", axis.title=c("Pejorative Weight (z-standardized)", "P300 Amplitude (z-standardized)"), colors = "Dark2") +
  309. theme(legend.position = "bottom") + ylim(-0.6, 0.6)
  310. plot(all_plot)
  311. ggsave("./plots/all_plot_P300.png", dpi=300, width=2000, height=1200, units="px")
  312. ## plot model estimates
  313. est_plot <- plot_model(model, type="est", colors="Set1", title="", axis.lim = c(-2.5, 2.5),
  314. axis.labels = c("Coh * Quot * Pej.Weight", "Quotation * Pejorative Weight",
  315. "Coherence * Pejorative Weight", "Coherence * Quotation",
  316. "Pejorative Weight", "Quotation", "Coherence"
  317. )) + theme(axis.text.y = element_text(angle = 30)) +
  318. ylim(-0.25, 0.25)
  319. plot(est_plot)
  320. ggsave("./plots/est_plot_P300.png", dpi=300, width=1500, height=1800, units="px")
  321. ## combine plots
  322. combi_plot <- ggarrange(all_plot,
  323. ggarrange(QC_plot, est_plot, ncol=2, labels=c("B", "C")),
  324. nrow=2,
  325. labels="A")
  326. plot(combi_plot)
  327. ggsave("./plots/combi_plot_P300.png", dpi=300, width=2400, height=2400, units="px")
  328. ## Diagnostics plots
  329. sim_res <- simulateResiduals(fittedModel = model, plot = F)
  330. ### Normality of residuals
  331. plotQQunif(sim_res, testUniformity = F, testOutliers = F, testDispersion = F)
  332. ### Normality of random effects
  333. diag <- plot_model(model, type="diag")
  334. plot(diag[[2]]$Participant)
  335. plot(diag[[2]]$Word)
  336. plot(diag[[2]]$Channel)
  337. ### Homoskedasticity
  338. plot(diag[[4]])
  339. # LPP
  340. ## build and save model
  341. #model_full <- lmer(Amplitude_LPP ~ Coherence*Quotation*Pej.Value + (1 + Coherence*Quotation*Pej.Value|Participant) + (1 + Quotation*Pej.Value|Word) + (1 + Coherence*Quotation*Pej.Value|Channel),
  342. # data=LPP_df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  343. #save(model_full, file="LPP_model_full.rda")
  344. #load("LPP_model_full.rda")
  345. #summary(model_full)
  346. #model_nochslopes <- lmer(Amplitude_LPP ~ Coherence*Quotation*Pej.Value + (1 + Coherence*Quotation*Pej.Value||Participant) + (1 + Quotation*Pej.Value||Word) + (1|Channel),
  347. # data=LPP_df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  348. #save(model_nochslopes, file="LPP_model_nochslopes")
  349. #load("LPP_model_nochslopes.rda")
  350. #summary(model_nochslopes)
  351. #model_inter_nochslopes <- lmer(Amplitude_LPP ~ Coherence*Quotation*Pej.Value + (1 + Coherence:Quotation:Pej.Value|Participant) + (1 + Quotation:Pej.Value|Word) + (1|Channel),
  352. # data=LPP_df_long, verbose=1, control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
  353. #save(model_inter_nochslopes, file="LPP_model_inter_nochslopes.rda")
  354. #load("LPP_model_inter_nochslopes.rda")
  355. #summary(model_inter_nochslopes)
  356. #model <- model_inter_nochslopes
  357. #save(model, file="LPP_model.rda")
  358. ##load model
  359. load("LPP_model.rda")
  360. ## model summary
  361. model_sum <- summary(model)
  362. print(model_sum)
  363. write.csv(model_sum$coefficients, "./csvs/combined_model_summary_LPP.csv")
  364. ## estimated marginal means
  365. emmeans(model, pairwise ~ Quotation, adjust="holm")
  366. emmeans(model, pairwise ~ Coherence, adjust="holm")
  367. emtrends(model, pairwise ~ Coherence, var = "Pej.Value", adjust="holm")
  368. emm_means <- emmeans(model, ~ Coherence*Quotation)
  369. emm_means
  370. emm_contrasts <- contrast(emm_means, list(c(1, -1, 0, 0), c(0, 0, 1, -1), c(0, 1, 0, -1), c(1, 0, -1, 0)), adjust="holm")
  371. emm_contrasts
  372. emm_means_df <- as.data.frame(emm_means)
  373. emm_contrasts_df <- as.data.frame(emm_contrasts) %>% mutate(contrast = str_replace_all(contrast, "C ", "C-"))
  374. eta_squared(model, partial=TRUE)
  375. ## define plots variables
  376. means <- emm_means_df$emmean
  377. SEs <- emm_means_df$SE
  378. max_NoQM <- max((means+SEs)[1:2])
  379. max_QM <- max((means+SEs)[3:4])
  380. ## plot group differences
  381. QC_plot <- ggplot(emm_means_df, aes(x = Quotation, y = emmean, color = Coherence)) +
  382. ylim(-0.6, 0.6) +
  383. geom_point(position = position_dodge(width = 0.3), size=3) +
  384. geom_errorbar(aes(ymin = means-SEs, ymax = means+SEs),
  385. position = position_dodge(width = 0.3), # Shift error bars
  386. linewidth = 0.8, # Make error bars thicker
  387. width = 0.2) +
  388. labs(title = "",
  389. x = "Quotation",
  390. y = "LPP Amplitude (z-standardized)",
  391. color = "Coherence") +
  392. theme(text = element_text(size=14)) +
  393. geom_signif(y_position = c(max_QM+0.08, max_QM+0.08, max_QM+0.115, max_QM+0.25),
  394. xmin = c(0.925, 1.925, 1, 1),
  395. xmax = c(1.075, 2.075, 2, 2),
  396. annotation = c("", "", "*", "***"),
  397. tip_length = 0.1, color="black") +
  398. scale_color_brewer(palette="Dark2") +
  399. theme(legend.position = "bottom")
  400. plot(QC_plot)
  401. ggsave("./plots/QC_plot_LPP.png", dpi=300, width=1000, height=1200, units="px")
  402. ## plot three-way interactions
  403. all_plot <- plot_model(model, type="pred", terms=c("Pej.Value", "Coherence", "Quotation"), title="", axis.title=c("Pejorative Weight (z-standardized)", "LPP Amplitude (z-standardized)"), colors = "Dark2") +
  404. theme(legend.position = "bottom") + ylim(-0.6, 0.6)
  405. plot(all_plot)
  406. ggsave("./plots/all_plot_LPP.png", dpi=300, width=2000, height=1200, units="px")
  407. ## plot model estimates
  408. est_plot <- plot_model(model, type="est", colors="Set1", title="", axis.lim = c(-2.5, 2.5),
  409. axis.labels = c("Coh * Quot * Pej.Weight", "Quotation * Pejorative Weight",
  410. "Coherence * Pejorative Weight", "Coherence * Quotation",
  411. "Pejorative Weight", "Quotation", "Coherence"
  412. )) + theme(axis.text.y = element_text(angle = 30)) +
  413. ylim(-0.25, 0.25)
  414. plot(est_plot)
  415. ggsave("./plots/est_plot_LPP.png", dpi=300, width=1500, height=1800, units="px")
  416. ## combine plots
  417. combi_plot <- ggarrange(all_plot,
  418. ggarrange(QC_plot, est_plot, ncol=2, labels=c("B", "C")),
  419. nrow=2,
  420. labels="A")
  421. plot(combi_plot)
  422. ggsave("./plots/combi_plot_LPP.png", dpi=300, width=2400, height=2400, units="px")
  423. ## Diagnostics plots
  424. sim_res <- simulateResiduals(fittedModel = model, plot = F)
  425. ### Normality of residuals
  426. plotQQunif(sim_res, testUniformity = F, testOutliers = F, testDispersion = F)
  427. ### Normality of random effects
  428. diag <- plot_model(model, type="diag")
  429. plot(diag[[2]]$Participant)
  430. plot(diag[[2]]$Word)
  431. plot(diag[[2]]$Channel)
  432. ### Homoskedasticity
  433. plot(diag[[4]])

polpejEEG_repo.R, no license · at the source

Overview

Authors: Manuel Hons1, Edgar Onea2, Ilse Schiller1, Silvia Erika Kober1
  1. Department of Psychology, University of Graz, Graz, Austria
  2. Department of German Studies, University of Graz, Graz, Austria
Institutions: University of Graz (Austria)
Journal: Frontiers in human neuroscience, volume 20, article 1820376
Dates: received 1 March 2026; accepted 11 June 2026; published online 29 June 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3389/fnhum.2026.1820376 · PMID 42444843 · PMCID PMC13357823 · OpenAlex W7166568562
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: EEG (modality), systems (subfield)
Methods: Preprocessing, Spectral & time-frequency, Statistics, Smoothing, state filtering, decompositions, Connectivity, Evoked potentials, Physiology & signal measures
Keywords: contextual violations, ERP, N400, political discourse, pragmatics
Topic: Neurobiology of Language and Bilingualism (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Citations: not cited yet (Europe PMC); 66 references in the paper

Abstract

Introduction: Pragmatic violations are known to elicit reliable N400 modulations in event related potentials of electroencephalographic recordings. While this effect has been extensively documented in linguistic contexts, evidence from political discourse remains limited. To address this gap, the present study investigated neural responses to socio-pragmatic coherence in politically framed statements.

Methods: Participants read political utterances containing critical target words that were either coherent or incoherent with a preceding description of the producer. To examine whether pragmatic processing could be altered by typographic cues, target words were presented either unmarked or enclosed in quotation marks.

Results: Consistent with prior findings, pragmatically incoherent target words elicited a larger negative deflection peaking around 400 ms post-onset than coherent words. Notably, this pattern was reversed when target words were presented in quotation marks.

Discussion: We interpret this reversal as evidence that quotation marks signal a rejection or distancing from a word’s conventional meaning, thereby altering contextual integration demands. While rejecting the meaning of incoherent terms (e.g., “climate terrorists”) may facilitate integration when aligned with the speaker’s stance, rejecting the meaning of coherent terms (e.g., “climate activists”) appears to increase processing difficulty. These findings demonstrate that typographic cues can modulate socio-pragmatic interpretation in political language, with measurable neural consequences.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 2 matches between paragraphs and lines of code.

OSF sgbqf

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: R (1)
Size: 7 files, 1 script
Software Heritage: not checked
Found in: the text, “Participants”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: easystats (1 file), emmeans (1 file), ggplot2 (1 file), ggpubr (1 file), glmmTMB (1 file), lme4 (1 file), lmerTest (1 file), tidyverse (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
1 file
At the source: osf.io/sgbqf

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 1 script, each with its path and the digest of its content;
  • 2 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability statement

The datasets presented in this study can be found in online repositories. The names of the repository/repositories and accession number(s) can be found in the article/Supplementary material.

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 2, 28 September 2026

  • Funding: added Karl-Franzens-Universität Graz

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 4 authors, 5 keywords, 61 references.

Cite

This paper

Hons, M., Onea, E., Schiller, I., & Kober, S. E. (2026). The neural dynamics of political socio-pragmatic violations: an ERP study. Frontiers in human neuroscience, 20, 1820376. https://doi.org/10.3389/fnhum.2026.1820376

BibTeX

@article{hons2026neural,
author = {Hons, Manuel and Onea, Edgar and Schiller, Ilse and Kober, Silvia Erika},
title = {{The neural dynamics of political socio-pragmatic violations: an ERP study}},
journal = {Frontiers in human neuroscience},
year = {2026},
month = jun,
volume = {20},
pages = {1820376},
publisher = {Frontiers Media SA},
issn = {1662-5161},
doi = {10.3389/fnhum.2026.1820376},
url = {https://doi.org/10.3389/fnhum.2026.1820376},
pmid = {42444843},
pmcid = {PMC13357823}
}

RIS

TY - JOUR
AU - Hons, Manuel
AU - Onea, Edgar
AU - Schiller, Ilse
AU - Kober, Silvia Erika
TI - The neural dynamics of political socio-pragmatic violations: an ERP study
T2 - Frontiers in human neuroscience
J2 - Front Hum Neurosci
PY - 2026
DA - 2026/06/29
VL - 20
SP - 1820376
SN - 1662-5161
PB - Frontiers Media SA
DO - 10.3389/fnhum.2026.1820376
UR - https://doi.org/10.3389/fnhum.2026.1820376
LA - en
ER -

CSL-JSON

{
"id": "10.3389/fnhum.2026.1820376",
"type": "article-journal",
"title": "The neural dynamics of political socio-pragmatic violations: an ERP study",
"container-title": "Frontiers in human neuroscience",
"author": [
{
"family": "Hons",
"given": "Manuel"
},
{
"family": "Onea",
"given": "Edgar"
},
{
"family": "Schiller",
"given": "Ilse"
},
{
"family": "Kober",
"given": "Silvia Erika"
}
],
"container-title-short": "Front Hum Neurosci",
"volume": "20",
"page": "1820376",
"DOI": "10.3389/fnhum.2026.1820376",
"PMID": "42444843",
"PMCID": "PMC13357823",
"ISSN": "1662-5161",
"publisher": "Frontiers Media SA",
"URL": "https://doi.org/10.3389/fnhum.2026.1820376",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
29
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1111/nyas.15407 [code]
Foreign cultural norms are better accepted in the second language.
Journal: Annals of the New York Academy of Sciences
In common: easystats, emmeans, lmerTest, 3 other tools, EEG, 5 references
[2] doi:10.1016/j.dcn.2023.101251 [code]
Age and vocabulary knowledge differentially influence the N400 and theta responses during semantic retrieval.
Journal: Developmental cognitive neuroscience
In common: easystats, emmeans, lmerTest, 4 other tools, EEG, 3 references
[3] doi:10.1162/nol_a_00078 [code]
Can You Hear What's Coming? Failure to Replicate ERP Evidence for Phonological Prediction.
Journal: Neurobiology of language (Cambridge, Mass.)
In common: easystats, emmeans, lmerTest, 4 other tools, EEG, 3 references
[4] doi:10.1162/imag_a_00297 [code]
Tone language experience enhances dimension-selective attention and subcortical encoding but not cortical entrainment to pitch.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: glmmTMB, easystats, emmeans, 5 other tools, 2 references
[5] doi:10.1038/s41598-025-34117-w [code]
The impact of awareness on affective emoji priming in visual word recognition.
Journal: Scientific reports
In common: easystats, emmeans, lmerTest, 3 other tools, EEG, 4 references
[6] doi:10.1523/jneurosci.0657-25.2025 [code]
Attentional Engagement with Target and Distractor Streams Predicts Speech Comprehension in Multitalker Environments.
Journal: The Journal of neuroscience : the official journal of the Society for Neuroscience
In common: glmmTMB, emmeans, lmerTest, 3 other tools, EEG, 3 references
[7] doi:10.3758/s13415-026-01401-9 [code]
Dissociable impacts of perceived race and ascribed status in event-related brain potentials and multivariate network activity.
Journal: Cognitive, affective & behavioral neuroscience
In common: easystats, emmeans, lmerTest, 3 other tools, EEG, 3 references
[8] doi:10.3390/brainsci16040375 [code]
Comparing Brain Responses to Moral and Semantic Violations.
Journal: Brain sciences
In common: lmerTest, lme4, ggplot2, 1 other tool, EEG, 5 references
[9] doi:10.1007/s42113-024-00210-y [code]
Mnemonic vs. Executive Contributions to the N400: A Connectionist Approach to False Memories.
Journal: Computational brain & behavior
In common: easystats, emmeans, lmerTest, 3 other tools, EEG, 3 references
[10] doi:10.1038/s41398-026-04479-4 [code]
Altered semantic prediction error processing with increasing schizotypal and autistic traits.
Journal: Translational psychiatry
In common: easystats, emmeans, lmerTest, 4 other tools, EEG, 2 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.3389/fnhum.2026.1820376.svg)](https://openscicode.org/badge/doi/10.3389/fnhum.2026.1820376)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.3389/fnhum.2026.1820376.svg
   :target: https://openscicode.org/badge/doi/10.3389/fnhum.2026.1820376
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.3389/fnhum.2026.1820376"><img src="https://openscicode.org/badge/doi/10.3389/fnhum.2026.1820376.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.