Code
cat('\014') # clean terminalCode
rm(list = ls()) # clean workspace
library(tidyverse)
library(afex)
library(emmeans)
library(effectsize)
library(GGally)Recordings with EMOTIV EPOC Flex Gel, 32 channels
cat('\014') # clean terminalrm(list = ls()) # clean workspace
library(tidyverse)
library(afex)
library(emmeans)
library(effectsize)
library(GGally)emm_options(pbkrtest.limit = 5000)
my_dodge <- .3
my_jitter <- .2
theme_set(theme_minimal())
a_posteriori_aov_ez <- function(aov_ez_object, sig_level = .05) {
factors <- as.list(rownames(aov_ez_object$anova_table))
for (j in 1:length(factors)) {
if (grepl(':', factors[[j]])) {
factors[[j]] <- unlist(strsplit(factors[[j]], ':'))
}
}
p_values <- aov_ez_object$anova_table$`Pr(>F)`
for (i in 1:length(p_values)) {
if (p_values[i] <= sig_level) {
cat(rep('_', 60), '\n', sep = '')
print(emmeans(aov_ez_object, factors[[i]], contr = 'pairwise'))
}
}
}
a_posteriori_lmer <- function(lmer_obj, sig_level = .05) {
anova_lmer <- anova(lmer_obj)
factors <- as.list(row.names(anova_lmer))
for (j in 1:length(factors)) {
if (grepl(':', factors[[j]])) {
factors[[j]] <- unlist(strsplit(factors[[j]], ':'))
}
}
p_values <- anova_lmer$`Pr(>F)`
for (i in 1:length(p_values)) {
if (p_values[i] <= sig_level) {
cat(rep('_', 60), '\n', sep = '')
print(emmeans(lmer_obj, factors[[i]], contr = 'pairwise'))
}
}
}
a_posteriori_glmer <- function(glmer_obj, sig_level = .05) {
anova_glmer <- car::Anova(glmer_obj)
factors <- as.list(row.names(anova_glmer))
for (j in 1:length(factors)) {
if (grepl(':', factors[[j]])) {
factors[[j]] <- unlist(strsplit(factors[[j]], ':'))
}
}
p_values <- anova_glmer$`Pr(>Chisq)`
print(anova_glmer)
for (i in 1:length(p_values)) {
if (p_values[i] <= sig_level) {
cat(rep('_', 60), '\n', sep = '')
print(emmeans(glmer_obj, factors[[i]], contr = 'pairwise'))
}
}
}
xclude <- c(15, 22, 24, 36, 44)csv_answers <- list.files(path = '../csv', full.names = TRUE)
answers_df <- vroom::vroom(csv_answers, col_types = c(Sex = 'c'), show_col_types = FALSE) |>
filter(Block > 0) |>
mutate(Block = factor(Block)) |>
filter(!is.na(Question)) |>
mutate(file_info = str_extract(Subject, '.+?(?=_202)')) |>
mutate(Sex = if_else(Sex == 'f', 'female', 'male')) |>
separate(file_info, c('Version', 'ID', 'Group', 'City'), sep = '_', remove = FALSE) |>
mutate(Version = tolower(Version),
Group = tolower(Group),
Group = str_replace(Group, 'suv', 'vul'),
Group = if_else(Group == 'vul', 'vulnerable', 'control'),
Group = fct_relevel(Group, 'vulnerable'),
num_id = parse_number(ID),
Question = recode(Question, 'unpleasantness' = 'displeasing', 'pain' = 'painful'),
Stimulus = case_match(Valence, 'EASE' ~ 'no_pain', 'PAIN' ~ 'pain'),
City = case_match(City, 's' ~ 'stgo', 'v' ~ 'viña')) |>
mutate_if(is.character, as.factor) |>
relocate(Subject, .after = last_col()) |>
filter(!(num_id %in% xclude))
write.csv(answers_df, 'data/painEmpathy_2024_answers_clean_by_subject.csv', row.names = FALSE)
erp_averages <- list.files(path = './data/ave_volt_by_subject', full.names = TRUE)
painEmpathy_data <- vroom::vroom(erp_averages, show_col_types = FALSE) |>
separate(ERPset, c('ID', 'Group', 'City'), sep = '_', remove = FALSE) |>
rename(Component = mlabel,
Amplitude = value,
Stimulus = binlabel,
Electrode = chlabel) |>
mutate(Group = if_else(Group == 'vul', 'vulnerable', 'control'),
Group = fct_relevel(Group, 'vulnerable'),
City = case_match(City, 's' ~ 'stgo', 'v' ~ 'viña'),
worklat = gsub('.0', '', worklat, fixed = TRUE),
num_id = parse_number(ID),
chindex = factor(chindex),
bini = factor(bini)) |>
left_join(unique(answers_df[c('num_id', 'Sex')]), by = 'num_id') |>
mutate_if(is.character, as.factor) |>
mutate(Component = factor(Component, levels = c('N1', 'N2', 'P1', 'P3', 'LPP', 'P3a', 'P3b')),
Electrode = factor(Electrode, levels = c('FC1', 'Fz', 'FC2',
'CP1', 'Cz', 'CP2',
'O1' , 'Oz', 'O2')),
Lateral = case_match(Electrode,
c('FC1', 'CP1', 'O1') ~ 'left',
c('Fz' , 'Cz' , 'Oz') ~ 'center',
c('FC2', 'CP2', 'O2') ~ 'right')) |>
filter(!(num_id %in% xclude))
write.csv(painEmpathy_data, file.path('data/painEmpathy_2024_erp_clean_by_subject.csv'), row.names = FALSE)
n1_data <- subset(painEmpathy_data, Component == 'N1',)
n2_data <- subset(painEmpathy_data, Component == 'N2',)
p1_data <- subset(painEmpathy_data, Component == 'P1',)
p3_data <- subset(painEmpathy_data, Component == 'P3',)
lpp_data <- subset(painEmpathy_data, Component == 'LPP',)
p3a_data <- subset(painEmpathy_data, Component == 'P3a',)
p3b_data <- subset(painEmpathy_data, Component == 'P3b',)
component_data_wide_stimulus <- painEmpathy_data[c('num_id', 'Stimulus', 'Lateral', 'Component', 'Amplitude')] |>
mutate(Stimulus = fct_relevel(Stimulus, 'pain')) |>
pivot_wider(names_from = Component, values_from = Amplitude)ans_table <- xtabs(~ Sex + Group, data = unique(answers_df[c('num_id', 'Sex', 'Group')]))
addmargins(ans_table, margin = c(1, 2)) Group
Sex vulnerable control Sum
female 25 25 50
male 25 25 50
Sum 50 50 100
cat(rep('_', 60), '\n', sep = '')____________________________________________________________
ans_table <- xtabs(~ Sex + Group + City, data = unique(answers_df[c('num_id', 'Sex', 'Group', 'City')]))
addmargins(ans_table, margin = c(1, 2)), , City = stgo
Group
Sex vulnerable control Sum
female 25 18 43
male 24 20 44
Sum 49 38 87
, , City = viña
Group
Sex vulnerable control Sum
female 0 7 7
male 1 5 6
Sum 1 12 13
summary(answers_df) Sex Block trialN Image Valence
female:4915 1:4969 Min. : 1.00 54.1.jpg: 48 EASE:4875
male :4926 2:4872 1st Qu.:16.00 9.1.jpg : 48 PAIN:4966
Median :32.00 hp-1 : 48
Mean :31.49 2.2.jpg : 47
3rd Qu.:47.00 43.2.jpg: 47
Max. :64.00 hnp-10 : 47
(Other) :9556
Answer Question rT Session
Min. : 1.00 displeasing:4927 Min. : 2 Min. :1
1st Qu.:17.00 painful :4914 1st Qu.: 3115 1st Qu.:1
Median :49.00 Median : 3995 Median :1
Mean :44.86 Mean : 4455 Mean :1
3rd Qu.:72.00 3rd Qu.: 5143 3rd Qu.:1
Max. :97.00 Max. :68437 Max. :1
file_info Version ID Group
pev1_s133_ctl_s: 66 pev1:4728 s113 : 119 vulnerable:4854
pev1_s113_ctl_s: 62 pev2:5113 s133 : 119 control :4987
pev2_s006_vul_s: 61 s127 : 117
pev2_s040_vul_s: 61 s147 : 112
pev2_s126_ctl_s: 61 s035 : 111
pev2_s134_ctl_s: 61 s037 : 111
(Other) :9469 (Other):9152
City num_id Stimulus
stgo:8569 Min. : 1.00 no_pain:4875
viña:1272 1st Qu.: 29.00 pain :4966
Median :100.00
Mean : 77.41
3rd Qu.:126.00
Max. :150.00
Subject
pev1_s133_ctl_s_2025-01-20_18-45-53: 66
pev1_s113_ctl_s_2024-12-23_14-53-17: 62
pev2_s006_vul_s_2024-10-25_18-31-33: 61
pev2_s040_vul_s_2024-11-29_14-50-53: 61
pev2_s126_ctl_s_2025-01-17_21-06-11: 61
pev2_s134_ctl_s_2025-01-22_15-26-40: 61
(Other) :9469
pain_rating_lmer <- lmer(Answer ~ Group*Sex*Stimulus + (Stimulus|num_id) + (1|Image), subset(answers_df, Question == 'painful'))
afex_plot(
pain_rating_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .1),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 4)
)
pain_rating_lmer@calllmer(formula = Answer ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | Image), data = subset(answers_df, Question ==
"painful"))
anova(pain_rating_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 1406 1406 1 95.887 4.5557 0.035359 *
Sex 44 44 1 95.809 0.1417 0.707419
Stimulus 149242 149242 1 122.826 483.5587 < 2.2e-16 ***
Group:Sex 0 0 1 95.820 0.0011 0.974213
Group:Stimulus 3379 3379 1 95.734 10.9472 0.001322 **
Sex:Stimulus 88 88 1 95.679 0.2838 0.595487
Group:Sex:Stimulus 81 81 1 95.687 0.2630 0.609217
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(pain_rating_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.04 | [0.00, 0.13] | small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.79 | [0.73, 0.84] | large
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 0.09 | [0.01, 0.22] | medium
Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
- Interpretation rule: field2013
a_posteriori_lmer(pain_rating_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Group emmean SE df lower.CL upper.CL
vulnerable 49.3 1.25 116 46.8 51.8
control 45.7 1.25 114 43.2 48.2
Results are averaged over the levels of: Sex, Stimulus
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
vulnerable - control 3.6 1.69 96 2.134 0.0354
Results are averaged over the levels of: Sex, Stimulus
Degrees-of-freedom method: kenward-roger
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Stimulus emmean SE df lower.CL upper.CL
no_pain 24.1 1.58 120 21.0 27.2
pain 70.9 1.21 141 68.5 73.3
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
no_pain - pain -46.8 2.13 123 -21.990 <.0001
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Group Stimulus emmean SE df lower.CL upper.CL
vulnerable no_pain 29.2 2.17 108 24.9 33.5
control no_pain 19.0 2.17 108 14.7 23.3
vulnerable pain 69.4 1.63 120 66.1 72.6
control pain 72.4 1.62 117 69.1 75.6
Results are averaged over the levels of: Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
vulnerable no_pain - control no_pain 10.19 2.98 96.0 3.417 0.0051
vulnerable no_pain - vulnerable pain -40.18 2.92 110.1 -13.778 <.0001
vulnerable no_pain - control pain -43.16 2.71 198.1 -15.911 <.0001
control no_pain - vulnerable pain -50.37 2.72 199.7 -18.532 <.0001
control no_pain - control pain -53.35 2.91 109.2 -18.337 <.0001
vulnerable pain - control pain -2.98 2.18 96.1 -1.371 0.5207
Results are averaged over the levels of: Sex
Degrees-of-freedom method: kenward-roger
P value adjustment: tukey method for comparing a family of 4 estimates
unpleasantness_rating_lmer <- lmer(Answer ~ Group*Sex*Stimulus + (Stimulus|num_id) + (1|Image), subset(answers_df, Question == 'displeasing'))
afex_plot(
unpleasantness_rating_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .1),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 4)
)
unpleasantness_rating_lmer@calllmer(formula = Answer ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | Image), data = subset(answers_df, Question ==
"displeasing"))
anova(unpleasantness_rating_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 8 8 1 95.879 0.0272 0.86926
Sex 327 327 1 95.870 1.0548 0.30699
Stimulus 97999 97999 1 129.735 315.7646 < 2e-16 ***
Group:Sex 3 3 1 95.876 0.0087 0.92599
Group:Stimulus 2004 2004 1 95.953 6.4571 0.01265 *
Sex:Stimulus 564 564 1 95.932 1.8186 0.18065
Group:Sex:Stimulus 157 157 1 95.946 0.5070 0.47819
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(unpleasantness_rating_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.00 | [0.00, 0.00] | very small
Sex | 5.60e-04 | [0.00, 0.04] | very small
Stimulus | 0.70 | [0.62, 0.76] | large
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 0.05 | [0.00, 0.16] | small
Sex:Stimulus | 8.29e-03 | [0.00, 0.08] | very small
Group:Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
- Interpretation rule: field2013
a_posteriori_lmer(unpleasantness_rating_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Stimulus emmean SE df lower.CL upper.CL
no_pain 24.4 1.59 120 21.3 27.6
pain 58.9 1.92 112 55.1 62.7
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
no_pain - pain -34.5 1.94 130 -17.770 <.0001
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Group Stimulus emmean SE df lower.CL upper.CL
vulnerable no_pain 26.9 2.18 108 22.6 31.3
control no_pain 21.9 2.18 108 17.6 26.2
vulnerable pain 56.8 2.66 104 51.6 62.1
control pain 60.9 2.66 104 55.6 66.2
Results are averaged over the levels of: Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
vulnerable no_pain - control no_pain 5.01 3.00 96 1.673 0.3438
vulnerable no_pain - vulnerable pain -29.92 2.64 113 -11.347 <.0001
vulnerable no_pain - control pain -34.00 3.44 171 -9.868 <.0001
control no_pain - vulnerable pain -34.93 3.44 171 -10.142 <.0001
control no_pain - control pain -39.01 2.64 113 -14.791 <.0001
vulnerable pain - control pain -4.07 3.69 96 -1.103 0.6886
Results are averaged over the levels of: Sex
Degrees-of-freedom method: kenward-roger
P value adjustment: tukey method for comparing a family of 4 estimates
EDF files were pre-processed in Matlab using the EEGLAB 2023.1 toolbox (Delorme and Makeig 2004), the ERPLAB 10.0 toolbox (Lopez-Calderon and Luck 2014), and automated with in-house scripts. EEG data was high-pass filtered at 0.1 Hz with a 12 dB/oct roll-off. A working time window was selected from 2 seconds before the first Stimulus to 2 seconds after the last one. Defective channels were identified by eye inspection and omitted from the preprocessing steps. Artifacts originating from eye blinks or movements, heart beats, muscle contraction, channel noise, or electrical interference were identified and removed by means of independent Component analysis (ICA) and using the ICLabel 1.4 classifier (Pion-Tonachini, Kreutz-Delgado, and Makeig 2019), Components with an score between 0.8 and 1 in the aforementioned artifactual categories were removed. At this point defective channels were spherically interpolated. Data was re-referenced to infinity with the REST 1.2 toolbox (Dong et al. 2017), low-pass filtered at 35 Hz with a 12 dB/oct roll-off, cut in [-200ms 1000ms] epochs around stimuli, and baseline-corrected relative to the mean voltage in the pre-Stimulus time.
ggplot(
painEmpathy_data, aes(x = Amplitude, fill = Component, color = Component)) +
geom_histogram(alpha = .4) +
facet_wrap(~Component, ncol = 1) +
theme(strip.text.x = element_blank())
erp_table <- xtabs(~ Sex + Group, data = unique(painEmpathy_data[c('num_id', 'Sex', 'Group')]))
addmargins(erp_table, margin = c(1, 2)) Group
Sex vulnerable control Sum
female 25 25 50
male 24 25 49
Sum 49 50 99
cat(rep('_', 60), '\n', sep = '')____________________________________________________________
erp_table <- xtabs(~ Sex + Group + City, data = unique(painEmpathy_data[c('num_id', 'Sex', 'Group', 'City')]))
addmargins(erp_table, margin = c(1, 2)), , City = stgo
Group
Sex vulnerable control Sum
female 25 18 43
male 24 20 44
Sum 49 38 87
, , City = viña
Group
Sex vulnerable control Sum
female 0 7 7
male 0 5 5
Sum 0 12 12
summary(painEmpathy_data) worklat Component Amplitude chindex Electrode
[105 135]:594 N1 :594 Min. :-9.5563 16 :792 O1 :792
[125 145]:594 N2 :594 1st Qu.:-0.6118 18 :792 Oz :792
[240 300]:594 P1 :594 Median : 1.3839 19 :792 O2 :792
[260 300]:594 P3 :594 Mean : 1.4826 2 :396 FC1 :396
[260 360]:594 LPP:594 3rd Qu.: 3.5449 6 :396 Fz :396
[340 390]:594 P3a:594 Max. :12.5529 29 :396 FC2 :396
[550 750]:594 P3b:594 (Other):594 (Other):594
bini Stimulus ERPset ID Group
5:2079 no_pain:2079 s001_vul_s: 42 s001 : 42 vulnerable:2058
6:2079 pain :2079 s002_vul_s: 42 s002 : 42 control :2100
s003_vul_s: 42 s003 : 42
s004_vul_s: 42 s004 : 42
s005_vul_s: 42 s005 : 42
s006_vul_s: 42 s006 : 42
(Other) :3906 (Other):3906
City num_id Sex Lateral
stgo:3654 Min. : 1.00 female:2100 Length:4158
viña: 504 1st Qu.: 28.00 male :2058 Class :character
Median :100.00 Mode :character
Mean : 76.87
3rd Qu.:126.00
Max. :150.00
Electrodes FC1, Fz, FC2
painEmpathy_n1_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), n1_data)
afex_plot(
painEmpathy_n1_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_n1_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = n1_data)
anova(painEmpathy_n1_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.04290 0.04290 1 94.997 0.2636 0.60883
Sex 0.03530 0.03530 1 94.997 0.2170 0.64243
Stimulus 0.09433 0.09433 1 95.004 0.5797 0.44832
Group:Sex 0.44957 0.44957 1 94.997 2.7628 0.09977 .
Group:Stimulus 0.00052 0.00052 1 95.004 0.0032 0.95484
Sex:Stimulus 0.40575 0.40575 1 95.004 2.4935 0.11764
Group:Sex:Stimulus 0.13089 0.13089 1 95.004 0.8044 0.37204
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(painEmpathy_n1_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.00 | [0.00, 0.00] | very small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex | 0.02 | [0.00, 0.10] | small
Group:Stimulus | 0.00 | [0.00, 0.00] | very small
Sex:Stimulus | 0.02 | [0.00, 0.10] | small
Group:Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_n1_lmer)Electrodes FC1, Fz, FC2
painEmpathy_n2_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), n2_data)
afex_plot(
painEmpathy_n2_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_n2_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = n2_data)
anova(painEmpathy_n2_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.89584 0.89584 1 95.001 4.7766 0.03131 *
Sex 0.00492 0.00492 1 95.001 0.0262 0.87172
Stimulus 0.37914 0.37914 1 95.000 2.0216 0.15836
Group:Sex 0.04783 0.04783 1 95.001 0.2550 0.61472
Group:Stimulus 0.20675 0.20675 1 95.000 1.1024 0.29641
Sex:Stimulus 0.08827 0.08827 1 95.000 0.4707 0.49435
Group:Sex:Stimulus 0.18951 0.18951 1 95.000 1.0105 0.31734
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(painEmpathy_n2_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.04 | [0.00, 0.14] | small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.01 | [0.00, 0.08] | small
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 1.05e-03 | [0.00, 0.05] | very small
Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex:Stimulus | 1.08e-04 | [0.00, 0.02] | very small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_n2_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Group emmean SE df lower.CL upper.CL
vulnerable -2.16 0.268 95 -2.70 -1.63
control -2.99 0.265 95 -3.51 -2.46
Results are averaged over the levels of: Sex, Stimulus
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
vulnerable - control 0.824 0.377 95 2.186 0.0313
Results are averaged over the levels of: Sex, Stimulus
Degrees-of-freedom method: kenward-roger
Electrodes O1, Oz, O2
painEmpathy_p1_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), p1_data)
afex_plot(
painEmpathy_p1_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_p1_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = p1_data)
anova(painEmpathy_p1_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.000011 0.000011 1 95.000 0.0001 0.9919
Sex 0.051201 0.051201 1 95.000 0.4713 0.4941
Stimulus 0.004452 0.004452 1 95.001 0.0410 0.8400
Group:Sex 0.225518 0.225518 1 95.000 2.0759 0.1529
Group:Stimulus 0.146213 0.146213 1 95.001 1.3459 0.2489
Sex:Stimulus 0.000587 0.000587 1 95.001 0.0054 0.9416
Group:Sex:Stimulus 0.067558 0.067558 1 95.001 0.6219 0.4323
interpret(omega_squared(painEmpathy_p1_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.00 | [0.00, 0.00] | very small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex | 0.01 | [0.00, 0.09] | small
Group:Stimulus | 3.55e-03 | [0.00, 0.06] | very small
Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_p1_lmer)Electrodes O1, Oz, O2
painEmpathy_p3_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), p3_data)
afex_plot(
painEmpathy_p3_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_p3_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = p3_data)
anova(painEmpathy_p3_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.1352 0.1352 1 95.028 1.0093 0.3176
Sex 0.0837 0.0837 1 95.028 0.6246 0.4313
Stimulus 3.5916 3.5916 1 94.999 26.8013 1.257e-06 ***
Group:Sex 0.0008 0.0008 1 95.028 0.0062 0.9376
Group:Stimulus 0.0114 0.0114 1 94.999 0.0853 0.7708
Sex:Stimulus 0.2042 0.2042 1 94.999 1.5238 0.2201
Group:Sex:Stimulus 0.1476 0.1476 1 94.999 1.1013 0.2966
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(painEmpathy_p3_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 9.53e-05 | [0.00, 0.02] | very small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.21 | [0.08, 0.35] | large
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 0.00 | [0.00, 0.00] | very small
Sex:Stimulus | 5.37e-03 | [0.00, 0.07] | very small
Group:Sex:Stimulus | 1.04e-03 | [0.00, 0.05] | very small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_p3_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Stimulus emmean SE df lower.CL upper.CL
no_pain 4.17 0.240 95 3.70 4.65
pain 3.73 0.232 95 3.27 4.19
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
no_pain - pain 0.446 0.0861 95 5.177 <.0001
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Electrodes CP1, Cz, CP2
painEmpathy_lpp_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), lpp_data)
afex_plot(
painEmpathy_lpp_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_lpp_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = lpp_data)
options(width = 120)
anova(painEmpathy_lpp_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.4467 0.4467 1 95.001 2.4523 0.1207
Sex 0.4629 0.4629 1 95.001 2.5410 0.1142
Stimulus 21.3824 21.3824 1 94.998 117.3843 <2e-16 ***
Group:Sex 0.0059 0.0059 1 95.001 0.0322 0.8579
Group:Stimulus 0.0012 0.0012 1 94.998 0.0066 0.9353
Sex:Stimulus 0.3922 0.3922 1 94.998 2.1532 0.1456
Group:Sex:Stimulus 0.3050 0.3050 1 94.998 1.6746 0.1988
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(painEmpathy_lpp_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.01 | [0.00, 0.09] | small
Sex | 0.02 | [0.00, 0.10] | small
Stimulus | 0.55 | [0.41, 0.64] | large
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 0.00 | [0.00, 0.00] | very small
Sex:Stimulus | 0.01 | [0.00, 0.09] | small
Group:Sex:Stimulus | 6.91e-03 | [0.00, 0.07] | very small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_lpp_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Stimulus emmean SE df lower.CL upper.CL
no_pain 1.13 0.0965 95 0.934 1.32
pain 1.88 0.0940 95 1.693 2.07
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
no_pain - pain -0.755 0.0697 95 -10.834 <.0001
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Electrodes O1, Oz, O2
painEmpathy_p3a_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), p3a_data)
afex_plot(
painEmpathy_p3a_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_p3a_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = p3a_data)
options(width = 110)
anova(painEmpathy_p3a_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.47323 0.47323 1 94.984 3.4934 0.0647 .
Sex 0.02515 0.02515 1 94.984 0.1856 0.6675
Stimulus 2.37251 2.37251 1 95.002 17.5140 6.365e-05 ***
Group:Sex 0.08415 0.08415 1 94.984 0.6212 0.4326
Group:Stimulus 0.01057 0.01057 1 95.002 0.0780 0.7806
Sex:Stimulus 0.08132 0.08132 1 95.002 0.6003 0.4404
Group:Sex:Stimulus 0.32056 0.32056 1 95.002 2.3664 0.1273
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(painEmpathy_p3a_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.03 | [0.00, 0.12] | small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.15 | [0.04, 0.28] | large
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 0.00 | [0.00, 0.00] | very small
Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex:Stimulus | 0.01 | [0.00, 0.09] | small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_p3a_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Stimulus emmean SE df lower.CL upper.CL
no_pain 4.28 0.287 95 3.71 4.85
pain 3.92 0.282 95 3.36 4.48
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
no_pain - pain 0.365 0.0872 95 4.185 0.0001
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Electrodes O1, Oz, O2
painEmpathy_p3b_lmer <- lmer(Amplitude ~ Group * Sex * Stimulus + (Stimulus | num_id) + (1 | num_id : Electrode), p3b_data)
afex_plot(
painEmpathy_p3b_lmer,
x = 'Stimulus',
trace = 'Group',
panel = 'Sex',
id = 'num_id',
error_arg = list(width = .25),
dodge = my_dodge,
data_arg = list(
position =
position_jitterdodge(
jitter.width = my_jitter,
jitter.height = 0,
dodge.width = my_dodge ## needs to be same as dodge
)),
mapping = c('color'),
point_arg = list(size = 3)
)
painEmpathy_p3b_lmer@calllmer(formula = Amplitude ~ Group * Sex * Stimulus + (Stimulus |
num_id) + (1 | num_id:Electrode), data = p3b_data)
options(width = 110)
anova(painEmpathy_p3b_lmer)Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
Group 0.01346 0.01346 1 95 0.0978 0.7552306
Sex 0.02017 0.02017 1 95 0.1464 0.7028396
Stimulus 1.66949 1.66949 1 95 12.1209 0.0007551 ***
Group:Sex 0.03880 0.03880 1 95 0.2817 0.5968504
Group:Stimulus 0.03646 0.03646 1 95 0.2647 0.6081131
Sex:Stimulus 0.04821 0.04821 1 95 0.3500 0.5555280
Group:Sex:Stimulus 0.02224 0.02224 1 95 0.1615 0.6886835
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interpret(omega_squared(painEmpathy_p3b_lmer, alternative = 'two.sided'), rules = 'field2013')# Effect Size for ANOVA (Type III)
Parameter | Omega2 (partial) | 95% CI | Interpretation
---------------------------------------------------------------------
Group | 0.00 | [0.00, 0.00] | very small
Sex | 0.00 | [0.00, 0.00] | very small
Stimulus | 0.10 | [0.02, 0.23] | medium
Group:Sex | 0.00 | [0.00, 0.00] | very small
Group:Stimulus | 0.00 | [0.00, 0.00] | very small
Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
Group:Sex:Stimulus | 0.00 | [0.00, 0.00] | very small
- Interpretation rule: field2013
a_posteriori_lmer(painEmpathy_p3b_lmer)____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
Stimulus emmean SE df lower.CL upper.CL
no_pain 3.81 0.198 95 3.42 4.20
pain 3.47 0.193 95 3.09 3.85
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
no_pain - pain 0.341 0.098 95 3.482 0.0008
Results are averaged over the levels of: Group, Sex
Degrees-of-freedom method: kenward-roger
n_ctl <- sum(unique(painEmpathy_data$num_id) >= 100)
n_vul <- sum(unique(painEmpathy_data$num_id) < 100)
n_fmut <- min(n_ctl, n_vul)Using 49 cases by group as FMUT only works with groups of equal size.
Fields and Kuperberg (2020)
max_dist value of 50 corresponds to an approximate distance of 5.24 cm (assuming a 56 cm great circle circumference head and that your electrode coordinates are based on an idealized spherical head with radius of 85.000000). Min/Max distances between all pairs of channels (in chanlocs units): 26.560450/169.891840 Median (semi-IQR) distance between all pairs of channels (in chanlocs units): 119.172654 (30.583399) Mean (SD) # of neighbors per channel: 2.6 (1.2) Median (semi-IQR) # of neighbors per channel: 2.0 (1.0) Min/max # of neighbors per channel: 0 to 4
painEmpathy_fmut_by_subject: 2 significant Stimulus cluster(s) out of 35 cluster 1 F-masss: 848 cluster 1 p-value: 0.0259 cluster 2 F-masss: 19905 cluster 2 p-value: 0.0001
Using all cases
Groppe, Urbach, and Kutas (2011)
max_dist value of 50 corresponds to an approximate distance of 5.24 cm (assuming a 56 cm great circle circumference head and that your electrode coordinates are based on an idealized spherical head with radius of 85.000000). Min/Max distances between all pairs of channels (in chanlocs units): 26.560450/169.891840 Median (semi-IQR) distance between all pairs of channels (in chanlocs units): 119.172654 (30.583399) Mean (SD) # of neighbors per channel: 2.6 (1.2) Median (semi-IQR) # of neighbors per channel: 2.0 (1.0) Min/max # of neighbors per channel: 0 to 4
painEmpathy_by_subject_ctl: 1 significant positive cluster(s) out of 12 cluster 1 t-masss: 2275 cluster 1 p-value: 0.0000 1 significant negative cluster(s) out of 19 cluster 1 t-masss: -267 cluster 1 p-value: 0.0308 painEmpathy_by_subject_vul: 1 significant positive cluster(s) out of 17 cluster 1 t-masss: 2900 cluster 1 p-value: 0.0000 0 significant negative cluster(s) out of 11