-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathR Code
More file actions
99 lines (79 loc) · 3.94 KB
/
R Code
File metadata and controls
99 lines (79 loc) · 3.94 KB
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
#The data and R code necessary to reproduce the main model fits from Medimorec, S., Milin, P., & Divjak, D. (in press). Working memory affects anticipatory behavior during implicit pattern learning. Psychological Research. https://doi.org/10.1007/s00426-019-01251-w
#Dataset available at https://doi.org/10.25500/00000379
library(readxl)
X426_2019_1251_MOESM2_ESM <- read_excel("426_2019_1251_MOESM2_ESM.xlsx")
View(X426_2019_1251_MOESM2_ESM)
saveRDS(X426_2019_1251_MOESM2_ESM, file = "X426_2019_1251_MOESM2_ESM.rds")
SRT = readRDS('X426_2019_1251_MOESM2_ESM.rds')
require(car)
require(jtools)
###ANTICIPATIONS, LEARNING BLOCKS (1-4)
LEARNING = SRT[SRT$BLOCK < '5', ]#learning blocks
LEARNING$BLOCK=as.factor(LEARNING$BLOCK)
LEARNING$ANTICIPATIONS=as.factor(LEARNING$ANTICIPATIONS)
LEARNING$CORRECT_ANTICIPATIONS=as.factor(LEARNING$CORRECT_ANTICIPATIONS)
###INTERACTON MODEL
print(summary(ANT.LEARN <-glmer(ANTICIPATIONS ~
BLOCK*WMC+(1|PARTICIPANT),
data=LEARNING,family = binomial,
control=glmerControl(optimizer='bobyqa'))),cor=FALSE) #
Anova(ANT.LEARN)
probe_interaction(ANT.LEARN,
pred = WMC,
modx = BLOCK,
cond.int = TRUE,
interval = FALSE, jnplot = TRUE, color.class = "Greys")
###CORRECT ANTICIPATIONS, LEARNING BLOCKS (1-4)
###NO-INTERACTION MODEL
print(summary(ACC.LEARN<-glmer(CORRECT_ANTICIPATIONS ~
BLOCK+WMC+(1|PARTICIPANT),
data=LEARNING,family = binomial,
control=glmerControl(optimizer='bobyqa'))),cor=FALSE) #
Anova(ACC.LEARN)
####ANTICIPATIONS, INTERFERENCE (BLOCK 4 vs. BLOCK 5)
INTERFERENCE = SRT[SRT$BLOCK=='4'|SRTdata$BLOCK=='5',]
INTERFERENCE$BLOCK=as.factor(INTERFERENCE$BLOCK)
INTERFERENCE$ANTICIPATIONS=as.factor(INTERFERENCE$ANTICIPATIONS)
INTERFERENCE$CORRECT_ANTICIPATIONS=as.factor(INTERFERENCE$CORRECT_ANTICIPATIONS)
###INTERACTION MODEL
print(summary(ANT.INT <-glmer(ANTICIPATIONS ~
BLOCK*WMC+(1|PARTICIPANT),
data=INTERFERENCE, family = binomial,
control=glmerControl(optimizer='bobyqa'))), cor=FALSE)
Anova(ANT.INT)
probe_interaction(ANT.INT,
pred = WMC,
modx = BLOCK,
cond.int = TRUE,
interval = FALSE, jnplot = TRUE, color.class = "Greys")
###CORRECT ANTICIPATIONS, INTERFERENCE (BLOCK 4 vs. BLOCK 5)
###NO-NTERACTION MODEL
print(summary(ACC.INT <-glmer(CORRECT_ANTICIPATIONS ~
BLOCK+WMC+(1|PARTICIPANT),
data=INTERFERENCE, family = binomial,
control=glmerControl(optimizer='bobyqa'))), cor=FALSE)
Anova(ACC.INT)
###ANTICIPATIONS, RECOVERY (BLOCK 5 vs. BLOCK 6)
RECOVERY = SRT[SRT$BLOCK>'4',]
RECOVERY$BLOCK=as.factor(RECOVERY$BLOCK)
RECOVERY$ANTICIPATIONS=as.factor(RECOVERY$ANTICIPATIONS)
RECOVERY$CORRECT_ANTICIPATIONS=as.factor(RECOVERY$CORRECT_ANTICIPATIONS)
###INTERACTION MODEL
print(summary(ANT.REC <-glmer(ANTICIPATIONS ~
BLOCK*WMC+(1|PARTICIPANT),
data=RECOVERY, family = binomial,
control=glmerControl(optimizer='bobyqa'))), cor=FALSE)
Anova(ANT.REC)
probe_interaction(ANT.REC,
pred = WMC,
modx = BLOCK,
cond.int = TRUE,
interval = FALSE, jnplot = TRUE, color.class = "Greys")
###CORRECT ANTICIPATIONS, RECOVERY (BLOCK 5 vs. BLOCK 6)
####NO-INTERACTION MODEL
print(summary(ACC.REC <-glmer(CORRECT_ANTICIPATIONS ~
BLOCK+WMC+(1|PARTICIPANT),
data=RECOVERY, family = binomial,
control=glmerControl(optimizer='bobyqa'))), cor=FALSE)
Anova(ACC.REC)
###End