-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepetitionPaper_SupplementalResults_withggplot.r
148 lines (122 loc) · 6.98 KB
/
RepetitionPaper_SupplementalResults_withggplot.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
rm(list=ls()) #borro todas las variables del workspace (rm)
library(lme4)
load("data_without_skips.Rda")
# Higher orders
data$rpt2 = data$rpt^2
data$rpt3 = data$rpt^3
data$sentence_border[data$sentence_border=="2"] = 0
# Center variables
data$rpt_noncentered = data$rpt
data$freq_noncentered = data$freq
data$Nlaunchsite<-scale(data$launchsite,scale=TRUE,center=TRUE)
data$invlength = scale(data$invlength,center=TRUE,scale=FALSE)
data$pinvlength = scale(data$pinvlength,center=TRUE,scale=FALSE)
data$freq = scale(data$freq,center=TRUE,scale=FALSE)
data$pfreq = scale(data$pfreq,center=TRUE,scale=FALSE)
data$rpl = scale(data$rpl,center=TRUE,scale=FALSE)
data$rpt = scale(data$rpt,center=TRUE,scale=FALSE)
data$rpt2 = scale(data$rpt2,center=TRUE,scale=FALSE)
data$rpt3 = scale(data$rpt3,center=TRUE,scale=FALSE)
data$rps = scale(data$rps,center=TRUE,scale=FALSE)
##########################################################################################################
# Supplementary Table 2: Baseline model
##########################################################################################################
B0<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
(1|sujid) + (1|textid) + (1|wordid), data = data)
print(summary(B0),cor=F)
# cB0<-confint(B0)
B1<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
rpl +
(1|sujid) + (1|textid) + (1|wordid), data = data)
print(summary(B1),cor=F)
# cB1<-confint(B1)
B2<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
rpl + rpt + rpt2 + rpt3 +
(1|sujid) + (1|textid) + (1|wordid), data = data)
print(summary(B2),cor=F)
# cB2<-confint(B2)
BaselineModel<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
rpl +
rpt + rpt2 + rpt3 +
rps + sentence_border +
(1|sujid) + (1|textid) + (1|wordid), data = data)
print(summary(BaselineModel),cor=F)
# cBaselineModel<-confint(BaselineModel)
anova(B0,B1,B2,BaselineModel)
##########################################################################################################
# Supplementary Figure 1: Word position in text
##########################################################################################################
source("./remef.v0.6.10.R")
library(ggplot2)
# A) Absolute (aligned to BGN, first 2K words)
data2 = data[data$rpt_abs<1975 & data$textid!=5,]
data2$rpt_abs1 = data2$rpt_abs
data2$rpt_abs2 = data2$rpt_abs1^2
data2$rpt_abs3 = data2$rpt_abs1^3
AbsoluteRPT_begin<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
rpl + rpt_abs1 + rpt_abs2 + rpt_abs3 +
(1|sujid) + (1|textid) + (1|wordid), data = data2)
nombres<-names(fixef(AbsoluteRPT_begin))
indices=which(is.element(nombres,c("(Intercept)","rpt_abs1","rpt_abs2","rpt_abs3")))
nombres[indices]
data2$remef1=remef(AbsoluteRPT_begin,ran=NULL,fix=indices,keep=TRUE)
data2$gd_remef=10^data2$remef1
# data2$gd_remef=10^remef(AbsoluteRPT_begin,ran="all")
ybreaks = seq(255, 285, 10)
xbreaks = seq(0, 2000, 500)
p <- ggplot(data2, aes(y=gd_remef, x = rpt_abs1) )
p <- p + scale_y_continuous(name="Gaze duration [ms]", breaks = (ybreaks), labels = as.character(ybreaks))
p <- p + stat_smooth(method = "lm", formula = y ~ poly(x,3), size = 1.2, colour = "black")
p <- p + scale_x_continuous(name = "Absolute Position-in-Text", breaks =(xbreaks), labels = as.character(xbreaks))
p <- p + coord_cartesian(xlim =(c(min(xbreaks), max(xbreaks))), ylim =(c(min(ybreaks), max(ybreaks))))
p <- p + theme_bw()
p <- p + theme(legend.position = "top")
p <- p + theme(strip.background = element_rect(colour = "darkgrey", fill = "lightgrey", size = .2))
p <- p + theme(text = element_text(size=20))
p
# B) Relative
data2 = data[data$textid!=5,]
RelativeRPT_begin<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
rpl + rpt + rpt2 + rpt3 +
(1|sujid) + (1|textid) + (1|wordid), data = data2)
nombres<-names(fixef(RelativeRPT_begin))
indices=which(is.element(nombres,c("(Intercept)","rpt","rpt2","rpt3")))
nombres[indices]
data2$remef1=remef(RelativeRPT_begin,ran=NULL,fix=indices,keep=TRUE)
data2$gd_remef=10^data2$remef1
xbreaks = seq(0, 1, 0.250)
p <- ggplot(data2, aes(y=gd_remef, x = rpt_noncentered) )
p <- p + scale_y_continuous(name="Gaze duration [ms]", breaks = (ybreaks), labels = as.character(ybreaks))
p <- p + stat_smooth(method = "lm", formula = y ~ poly(x,3), size = 1.2, colour = "black")
p <- p + scale_x_continuous(name = "Relative Position-in-Text", breaks =(xbreaks), labels = as.character(xbreaks))
p <- p + coord_cartesian(xlim =(c(min(xbreaks), max(xbreaks))), ylim =(c(min(ybreaks), max(ybreaks))))
p <- p + theme_bw()
p <- p + theme(legend.position = "top")
p <- p + theme(strip.background = element_rect(colour = "darkgrey", fill = "lightgrey", size = .2))
p <- p + theme(text = element_text(size=20))
p
# C) Absolute (aligned to END, last 2K words)
data2 = data[data$rpt_abs_end<1975 & data$textid!=5,]
data2$rpt_abs_end1 = data2$rpt_abs_end
data2$rpt_abs_end2 = data2$rpt_abs_end1^2
data2$rpt_abs_end3 = data2$rpt_abs_end1^3
AbsoluteRPT_end<-lmer(logFPRT ~ Nlaunchsite + invlength + pinvlength + freq + pfreq + invlength:freq +
rpl + rpt_abs_end1 + rpt_abs_end2 + rpt_abs_end3 +
(1|sujid) + (1|textid) + (1|wordid), data = data2)
nombres<-names(fixef(AbsoluteRPT_end))
indices=which(is.element(nombres,c("(Intercept)","rpt_abs_end1","rpt_abs_end2","rpt_abs_end3")))
nombres[indices]
data2$remef1=remef(AbsoluteRPT_end,ran=NULL,fix=indices,keep=TRUE)
data2$gd_remef=10^data2$remef1
data2$rpt_abs_end_remef=-(1975 - data2$rpt_abs_end1)
xbreaks = seq(-2000, 0, 250)
p <- ggplot(data2, aes(y=gd_remef, x = rpt_abs_end_remef) )
p <- p + scale_y_continuous(name="Gaze duration [ms]", breaks = (ybreaks), labels = as.character(ybreaks))
p <- p + stat_smooth(method = "lm", formula = y ~ poly(x,3), size = 1.2, colour = "black")
p <- p + scale_x_continuous(name = "Absolute Position-in-Text", breaks =(xbreaks), labels = as.character(xbreaks))
p <- p + coord_cartesian(xlim =(c(min(xbreaks), max(xbreaks))), ylim =(c(min(ybreaks), max(ybreaks))))
p <- p + theme_bw()
p <- p + theme(legend.position = "top")
p <- p + theme(strip.background = element_rect(colour = "darkgrey", fill = "lightgrey", size = .2))
p <- p + theme(text = element_text(size=20))
p