-
Notifications
You must be signed in to change notification settings - Fork 2
/
training_alvin2_analysis.R
111 lines (93 loc) · 3.02 KB
/
training_alvin2_analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Training study
# Alvin2 behavioural results
library(ggpubr)
library(readxl)
library(scales)
library(dplyr)
library(lme4)
# show ggplot2 colours
show_col(hue_pal()(2))
df <- read_excel("/media/eub/MyPassport/ABR-Training/RESULTS/Behavioural_Alvin2/training_both_alvin2_results_cleaned.xlsx")
# filename: "exp2_training_tone_discrimination.png"
# png("/media/eub/MyPassport/ABR-Training/Images/exp2_training_tone_discrimination.png",
# width = 1200, height = 600, units = "px")
ggline(df, x = "Session", y = "Correct",
color = "Native",
palette = c("#00BFC4", "#F8766D"),
facet.by = "Tone",
add = "mean") +
scale_y_continuous(labels = percent) +
labs(title = "Performance in tone discrimination tests",
x = "Session", y = "Correct responses")
#dev.off()
# plot discontinuous line
df_blank2 <-
structure(
list(
Stimulus = c(NA, NA),
Button = c(NA, NA),
Time = c(NA, NA),
`T/F_even/odd` = c(NA, NA),
Tone = c("Fall", "Rise"),
Result = c(NA, NA),
Correct = c(NA, NA),
Session = c(2, 2),
Native = c("English", "English")
),
row.names = c(NA,-2L),
class = c("tbl_df",
"tbl", "data.frame"))
df_with_blank <- bind_rows(df, df_blank2)
# use in the thesis (after correction)
# shows discontinuity in English participant's data
ggline(df_with_blank, x = "Session", y = "Correct",
color = "Native",
palette = c("#00BFC4", "#F8766D"),
facet.by = "Tone",
add = "mean") +
scale_y_continuous(labels = percent) +
labs(title = "Performance in tone discrimination tests",
x = "Session", y = "Correct responses")
# export
#ggsave("exp2_training_tone_discrimination.pdf",
# width = 6, height = 4)
### Anova
model_beh <- aov(Correct ~ Tone*Session,
df %>% filter(Native == "English"))
summary(model_beh)
plot(model_beh)
# descriptives
df %>% filter(Native == "English") %>% group_by(Tone) %>% summarise(mean(Correct))
df %>% filter(Native == "English") %>% group_by(Tone, Session) %>% summarise(mean(Correct))
# GLMM
df_with_blank$Native <- as.factor(df_with_blank$Native)
df_with_blank$Tone <- as.factor(df_with_blank$Tone)
df_with_blank$Session <- as.factor(df_with_blank$Session)
df_with_blank$Stimulus <- as.factor(df_with_blank$Stimulus)
# fit the models
library(lmerTest)
t1_beh_m1 <-
glmer(Correct ~ Native + Session + Tone +
(1 | Native),
#(1 + Stimulus | Native) # would not converge
family = "binomial",
data = df_with_blank %>% filter(Session != "2"))
summary(t1_beh_m1)
anova(t1_beh_m1)
# model 2
t1_beh_m2 <-
glmer(Correct ~ Native + Session +
(1 | Native),
family = "binomial",
data = df_with_blank %>% filter(Session != "2"))
# model 3
t1_beh_m3 <-
glmer(Correct ~ Native + Tone +
(1 | Native),
family = "binomial",
data = df_with_blank %>% filter(Session != "2"))
summary(t1_beh_m3)
anova(t1_beh_m3)
# compare two models
anova(t1_beh_m1, t1_beh_m2) # tone
anova(t1_beh_m1, t1_beh_m3) # session