Sys.setlocale("LC_ALL", "Czech")
options(encoding = "UTF-8")
library(bestNormalize)
library(sjPlot)
library(lmerTest)
library(ggplot2)
Load concession data, trim the response times 200 ms and below and 4000 and above, normalize the response times.
aqconc<-read.csv(file="aqconc.csv",fileEncoding = "UTF-16LE")
aqconc$cleanrt<-aqconc$rt
aqconc$cleanrt[aqconc$rt>4000|aqconc$rt<200]<-NA
aqconc$normclrt<-bestNormalize(aqconc$cleanrt,allow_orderNorm=F)$x.t
Load confrontation data, trim the response times 200 ms and below and 4000 and above, normalize the response times.
aqconf<-read.csv(file="aqconf.csv",fileEncoding = "UTF-16LE")
aqconf$cleanrt<-aqconf$rt
aqconf$cleanrt[aqconf$rt>4000|aqconf$rt<200]<-NA
aqconf$normclrt<-bestNormalize(aqconf$cleanrt,allow_orderNorm=F)$x.t
The following function calculates cell means and standard errors to be used in plots.
summarySE<- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
conf.interval=.95, .drop=TRUE) {
library(plyr)
# New version of length which can handle NA's: if na.rm==T, don't count them
length2 <- function (x, na.rm=FALSE) {
if (na.rm) sum(!is.na(x))
else length(x)
}
# This does the summary. For each group's data frame, return a vector with
# N, mean, and sd
datac <- ddply(data, groupvars, .drop=.drop,
.fun = function(xx, col) {
c(N = length2(xx[[col]], na.rm=na.rm),
mean = mean (xx[[col]], na.rm=na.rm),
sd = sd (xx[[col]], na.rm=na.rm)
)
},
measurevar
)
# Rename the "mean" column
datac <- rename(datac, c("mean" = measurevar))
datac$se <- datac$sd / sqrt(datac$N) # Calculate standard error of the mean
# Confidence interval multiplier for standard error
# Calculate t-statistic for confidence interval:
# e.g., if conf.interval is .95, use .975 (above/below), and use df=N-1
ciMult <- qt(conf.interval/2 + .5, datac$N-1)
datac$ci <- datac$se * ciMult
return(datac)
}
pd <- position_dodge(0.1)
aqconcsum<-summarySE(aqconc[aqconc$region1%in%c(6:10)&!is.na(aqconc$cleanrt),], measurevar="cleanrt", groupvars=c("condition","region1"))
outplot<-ggplot(aqconcsum, aes(x=factor(region1), y=cleanrt, group=factor(condition),linetype=factor(condition))) +
geom_errorbar(aes(ymin=cleanrt-se, ymax=cleanrt+se), width=.1,position=pd) +
geom_line(position=pd) +
geom_point(position=pd) +
scale_x_discrete("Region",breaks=c("6", "7","8", "9", "10"),
labels=c("\nPřesto\nYet", "Dál\ndál\nfurther","kupoval\nkupoval\nhe bought", "drahé\ndrahé\nexpensive","zbytečnosti\nzbytečnosti\nfutilities"))+
theme_bw()+
scale_linetype_manual(name="",
labels = c("Explicit",
"Implicit"),
values = c("0"="solid",
"1"="dashed"))+
labs(y="Reading time (ms)",x="")
outplot
The following code shows the results of mixed models:
aqconc7<-subset(aqconc, region1=="7")
aqconc8<-subset(aqconc, region1=="8")
aqconc9<-subset(aqconc, region1=="9")
aqconc10<-subset(aqconc, region1=="10")
xa<-lmer(normclrt~condition+(condition|subjv)+(1|item),data=aqconc7)
xb<-lmer(normclrt~condition+(condition|subjv)+(1|item),data=aqconc8)
xc<-lmer(normclrt~condition+(condition|subjv)+(1|item),data=aqconc9)
xd<-lmer(normclrt~condition+(condition|subjv)+(1|item),data=aqconc10)
tab_model(xa,xb,xc,xd,show.std=T,show.ci=F,show.est=F)
normclrt | normclrt | normclrt | normclrt | |||||
---|---|---|---|---|---|---|---|---|
Predictors | std. Beta | p | std. Beta | p | std. Beta | p | std. Beta | p |
(Intercept) | -0.02 | <0.001 | -0.02 | <0.001 | -0.04 | <0.001 | -0.02 | 0.430 |
condition | 0.21 | <0.001 | -0.01 | 0.624 | 0.02 | 0.225 | 0.04 | 0.008 |
Random Effects | ||||||||
σ2 | 0.33 | 0.32 | 0.28 | 0.34 | ||||
τ00 | 0.38 subjv | 0.35 subjv | 0.36 subjv | 0.48 subjv | ||||
0.02 item | 0.02 item | 0.06 item | 0.03 item | |||||
τ11 | 0.04 subjv.condition | 0.02 subjv.condition | 0.02 subjv.condition | 0.01 subjv.condition | ||||
ρ01 | -0.36 subjv | 0.09 subjv | -0.37 subjv | -0.26 subjv | ||||
ICC | 0.54 | 0.55 | 0.59 | 0.59 | ||||
N | 115 subjv | 115 subjv | 115 subjv | 115 subjv | ||||
20 item | 20 item | 20 item | 20 item | |||||
Observations | 2024 | 2028 | 2026 | 2010 | ||||
Marginal R2 / Conditional R2 | 0.043 / 0.556 | 0.000 / 0.547 | 0.000 / 0.589 | 0.002 / 0.591 |
aqconfsum<-summarySE(aqconf[aqconf$region1%in%c(6:10)&!is.na(aqconf$cleanrt),], measurevar="cleanrt", groupvars=c("condition","region1"))
outplot<-ggplot(aqconfsum, aes(x=factor(region1), y=cleanrt, group=factor(condition),linetype=factor(condition))) +
geom_errorbar(aes(ymin=cleanrt-se, ymax=cleanrt+se), width=.1,position=pd) +
geom_line(position=pd) +
geom_point(position=pd) +
scale_x_discrete("Region",breaks=c("6", "7","8", "9", "10"),
labels=c("\nZato\nBut", "V Praze\nv Praze\nin Prague","trvale\ntrvale\nsteadily", "mírně\nmírně\nslightly","stoupá\nstoupá\ngrows"))+
theme_bw()+
scale_linetype_manual(name="",
labels = c("Explicit",
"Implicit"),
values = c("0"="solid",
"1"="dashed"))+
labs(y="Reading time (ms)", x="")
outplot
aqconf7<-subset(aqconf, region1=="7")
aqconf8<-subset(aqconf, region1=="8")
aqconf9<-subset(aqconf, region1=="9")
aqconf10<-subset(aqconf, region1=="10")
xa<-lmer(normclrt~factor(condition)+(condition|subjv)+(condition|item),data=aqconf7)
xb<-lmer(normclrt~factor(condition)+(condition|subjv)+(condition|item),data=aqconf8)
xc<-lmer(normclrt~factor(condition)+(condition|subjv)+(condition|item),data=aqconf9)
xd<-lmer(normclrt~factor(condition)+(1|subjv)+(condition|item),data=aqconf10)
tab_model(xa,xb,xc,xd,show.std=T,show.est=F,show.ci=F)
normclrt | normclrt | normclrt | normclrt | ||||||
---|---|---|---|---|---|---|---|---|---|
Predictors | std. Beta | p | std. Beta | p | std. p | std. Beta | p | std. Beta | p |
(Intercept) | -0.23 | <0.001 | 0.04 | <0.001 | 0.680 | -0.01 | <0.001 | -0.07 | 0.015 |
condition [1] | 0.43 | <0.001 | -0.11 | 0.006 | 0.006 | -0.02 | 0.630 | 0.10 | 0.003 |
Random Effects | |||||||||
σ2 | 0.33 | 0.33 | 0.30 | 0.41 | |||||
τ00 | 0.40 subjv | 0.32 subjv | 0.28 subjv | 0.47 subjv | |||||
0.04 item | 0.05 item | 0.03 item | 0.03 item | ||||||
τ11 | 0.05 subjv.condition | 0.01 subjv.condition | 0.02 subjv.condition | 0.00 item.condition | |||||
0.01 item.condition | 0.01 item.condition | 0.01 item.condition | |||||||
ρ01 | -0.48 subjv | 0.09 subjv | -0.05 subjv | 0.03 item | |||||
-0.51 item | -0.52 item | -0.26 item | |||||||
ICC | 0.57 | 0.53 | 0.51 | 0.55 | |||||
N | 115 subjv | 115 subjv | 115 subjv | 115 subjv | |||||
20 item | 20 item | 20 item | 20 item | ||||||
Observations | 2122 | 2118 | 2120 | 2104 | |||||
Marginal R2 / Conditional R2 | 0.043 / 0.587 | 0.003 / 0.532 | 0.000 / 0.513 | 0.002 / 0.554 |