library(lme4)
library(plyr)
library(ggplot2)
library(afex)
library(ggthemes)
library(tidyverse)
library(kableExtra)
library(Hmisc)
library(binom)
library(Rmisc)
theme_alan <- function(base_size = 12 , base_family = "")
{
half_line <- base_size/2
colors <- ggthemes_data$few
gray <- colors$medium["gray"]
black <- colors$dark["black"]
theme(
line = element_line(colour = "black", size = 0.5, linetype = 1, lineend = "butt"),
rect = element_rect(fill = "white",
colour = "black", size = 0.5, linetype = 1),
text = element_text(family = base_family, face = "plain", colour = "black",
size = base_size, lineheight = 0.9, hjust = 0.5, vjust = 0.5,
angle = 0, margin = margin(), debug = FALSE),
axis.line = element_blank(),
axis.line.x = NULL,
axis.line.y = NULL,
axis.text = element_text(size = rel(0.8), colour = "grey30"),
axis.text.x = element_text(margin = margin(t = 0.8 * half_line/2), vjust = 1),
axis.text.x.top = element_text(margin = margin(b = 0.8 * half_line/2), vjust = 0),
axis.text.y = element_text(margin = margin(r = 0.8 * half_line/2), hjust = 1),
axis.text.y.right = element_text(margin = margin(l = 0.8 * half_line/2), hjust = 0),
axis.ticks = element_line(colour = "grey20"),
axis.ticks.length = unit(half_line/2, "pt"),
axis.title.x = element_text(margin = margin(t = half_line), vjust = 1),
axis.title.x.top = element_text(margin = margin(b = half_line), vjust = 0),
axis.title.y = element_text(angle = 90, margin = margin(r = half_line), vjust = 1),
axis.title.y.right = element_text(angle = -90, margin = margin(l = half_line), vjust = 0),
legend.background = element_rect(colour = NA),
legend.spacing = unit(0.4, "cm"),
legend.spacing.x = NULL,
legend.spacing.y = NULL,
legend.margin = margin(0.2, 0.2, 0.2, 0.2, "cm"),
legend.key = element_rect(fill = "white", colour = NA),
legend.key.size = unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
legend.text = element_text(size = rel(0.8)),
legend.text.align = NULL,
legend.title = element_text(hjust = 0),
legend.title.align = NULL,
legend.position = "right",
legend.direction = NULL,
legend.justification = "center",
legend.box = NULL,
legend.box.margin = margin(0, 0, 0, 0, "cm"),
legend.box.background = element_blank(),
legend.box.spacing = unit(0.4, "cm"),
panel.background = element_rect(fill = "white", colour = NA),
panel.border = element_rect(fill = NA, colour = "grey20"),
panel.grid.major = element_line(colour = "grey92"),
panel.grid.minor = element_line(colour = "grey92", size = 0.25),
panel.spacing = unit(half_line, "pt"),
panel.spacing.x = NULL,
panel.spacing.y = NULL,
panel.ontop = FALSE,
strip.background = element_rect(fill = "NA", colour = "NA"),
strip.text = element_text(colour = "grey10", size = rel(0.8)),
strip.text.x = element_text(margin = margin(t = half_line, b = half_line)),
strip.text.y = element_text(angle = 0, margin = margin(l = half_line, r = half_line)),
strip.placement = "inside",
strip.placement.x = NULL,
strip.placement.y = NULL,
strip.switch.pad.grid = unit(0.1, "cm"),
strip.switch.pad.wrap = unit(0.1, "cm"),
plot.background = element_rect(colour = "white"),
plot.title = element_text(size = rel(1.2), hjust = 0, vjust = 1, margin = margin(b = half_line * 1.2)),
plot.subtitle = element_text(size = rel(0.9), hjust = 0, vjust = 1, margin = margin(b = half_line * 0.9)),
plot.caption = element_text(size = rel(0.9), hjust = 1, vjust = 1, margin = margin(t = half_line * 0.9)),
plot.margin = margin(half_line, half_line, half_line, half_line),
complete = TRUE)
}
In Experiment 1, we explore the learnability of four different lexicons (in a between subjects design) that differ in the mapping between the features of labels and their meanings.
#Read in the data
Exp1Data <- read.csv("C:/Users/Alan/Google Drive/Experiments/Edinburgh Experiments/Experiment 5B- Motivated vs. Conventional/Data/5B Data CSV.csv")
#Relabel the Condition Column
Exp1Data$Condition <- factor(Exp1Data$Condition,
levels = c(1,2,3,4),
labels = c("Iconic", "Conventional", "Mixed Systematicity", "Counter-Iconic"))
#Add the BlockMinus Column
Exp1Data$BlockMinus <- Exp1Data$Block - 1
#Add in subconditions for Condition 2- Conventional mappings can go one of two ways and we need to take a look at those right away
Exp1DataSub <- subset(Exp1Data, Condition == "Conventional")
Exp1DataSub$Holder <- paste(Exp1DataSub$Condition, substr(Exp1DataSub$Label, 1,2), sep = "-")
Exp1DataSub$SubCondition1 <- grepl("th",Exp1DataSub$Label)
Exp1DataSub$SubCondition2 <- paste(Exp1DataSub$SubCondition1, Exp1DataSub$LabelType, sep = "-" )
Exp1DataSub$SubCondition3 <- mapvalues(Exp1DataSub$SubCondition2,
from = c("TRUE-C", "FALSE-S", "FALSE-C", "TRUE-S"),
to = c("A", "A", "B", "B"))
#Look at the difference between subconditions-
SubConditions <- data.frame(tapply(Exp1DataSub$RespCorr, Exp1DataSub$SubCondition3, mean))
colnames(SubConditions) <- "Proportion of Correct Responses"
knitr::kable(SubConditions, caption = 'Mean Proportion Correct by Subcondition') %>%
kable_styling()
| Proportion of Correct Responses | |
|---|---|
| A | 0.7916667 |
| B | 0.7897727 |
#Very basic statistical comparison
afex.Exp1Sub <- mixed(RespCorr ~ SubCondition3 * Block + (1|ID),
data=Exp1DataSub,
family=binomial,
control=glmerControl(optimizer="bobyqa"),
method = 'LRT',
progress=FALSE)
## Contrasts set to contr.sum for the following variables: ID
## Numerical variables NOT centered on 0: Block
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
afex.Exp1Sub$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: RespCorr ~ SubCondition3 * Block + (1 | ID)
## Data: Exp1DataSub
## Df full model: 5
## Df Chisq Chi Df Pr(>Chisq)
## SubCondition3 4 0.0157 1 0.9004
## Block 4 15.4034 1 8.683e-05 ***
## SubCondition3:Block 4 0.0534 1 0.8173
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Aggregating Data for Visualisation
Exp1SubAgg <- aggregate(RespCorr ~ SubCondition3 + Block + ID , data=Exp1DataSub, mean, na.rm= FALSE)
Exp1SubAgg$Block <- factor(Exp1SubAgg$Block)
#Plotting subconditions for visualisation
ggplot(data=Exp1SubAgg, aes(x=Block, y=RespCorr, group= SubCondition3)) +
#geom_line(aes(color= Condition)) +
#geom_point(size=1.75, aes(colour = Condition)) +
geom_smooth(method='loess', formula= y ~ x, se= TRUE, aes(linetype = SubCondition3)) +
# scale_linetype_manual(values = c("solid", "solid", "solid",
# "longdash", "longdash", "longdash", "dotdash",
# "dotted")) +
scale_color_manual(values= c("#0066CC", "#CC0033","#33FF00", "#000000")) +
labs(x="Block", y="Proportion of Correct Responses") +
scale_y_continuous(limits = c(0.45,1), breaks=c(0.5,0.6,0.7,0.8,0.9,1.0)) +
theme_tufte() +
ggtitle("Comparison of Conventional Subconditions of Experiment 1")
There definitely does not appear to be any difference between subconditions at all, nor an interaction of subcondition x block. This suggests that we can collapse those subconditions (and note a lack of difference between them in Experiment 1 Results section.)
Lets take a look then at the overall results
#Changed this analysis to afex - originally done with clunkier model comparison. Heartening that it yields the same results (and no convergence issues)
afex.Exp1 <- mixed(RespCorr ~ Condition * BlockMinus + (1+BlockMinus|ID),
data=Exp1Data,
family=binomial,
control=glmerControl(optimizer="bobyqa"),
method = 'LRT',
progress=FALSE)
afex.Exp1$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: RespCorr ~ Condition * BlockMinus + (1 + BlockMinus | ID)
## Data: Exp1Data
## Df full model: 11
## Df Chisq Chi Df Pr(>Chisq)
## Condition 8 19.0744 3 0.0002639 ***
## BlockMinus 10 64.1597 1 1.147e-15 ***
## Condition:BlockMinus 8 7.9971 3 0.0460711 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model1 <- glmer(RespCorr ~ Condition * BlockMinus + (1 + BlockMinus | ID),data=Exp1Data,family="binomial",control=glmerControl(optimizer="bobyqa"))
#relevel the Condition factor in the model to see if Mixed Systematicity is different from chance and from other levels
Exp1Data$ConditionP <- relevel(Exp1Data$Condition,ref="Mixed Systematicity")
#show the non-significant intercept of this model, which shows that Mixed Systematicity is not different from chance at Block 1
model1p <- glmer(RespCorr ~ ConditionP * BlockMinus + (1 + BlockMinus | ID),data=Exp1Data,family="binomial",control=glmerControl(optimizer="bobyqa"))
summary(model1p)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: RespCorr ~ ConditionP * BlockMinus + (1 + BlockMinus | ID)
## Data: Exp1Data
## Control: glmerControl(optimizer = "bobyqa")
##
## AIC BIC logLik deviance df.resid
## 5099.3 5173.1 -2538.6 5077.3 6037
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -11.5722 0.0778 0.2546 0.5160 1.3229
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ID (Intercept) 0.6997 0.8365
## BlockMinus 0.2996 0.5473 0.59
## Number of obs: 6048, groups: ID, 63
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.2399 0.2503 0.959 0.33780
## ConditionPIconic 1.5715 0.3416 4.600 4.23e-06
## ConditionPConventional 0.7439 0.3366 2.210 0.02712
## ConditionPCounter-Iconic 0.7532 0.3476 2.167 0.03023
## BlockMinus 0.4540 0.1721 2.638 0.00835
## ConditionPIconic:BlockMinus 0.5890 0.2585 2.278 0.02270
## ConditionPConventional:BlockMinus 0.4680 0.2434 1.923 0.05453
## ConditionPCounter-Iconic:BlockMinus 0.6563 0.2549 2.575 0.01003
##
## (Intercept)
## ConditionPIconic ***
## ConditionPConventional *
## ConditionPCounter-Iconic *
## BlockMinus **
## ConditionPIconic:BlockMinus *
## ConditionPConventional:BlockMinus .
## ConditionPCounter-Iconic:BlockMinus *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) CndtPI CndtPC CnPC-I BlckMn CPI:BM CPC:BM
## CondtnPIcnc -0.732
## CndtnPCnvnt -0.743 0.547
## CndtnPCnt-I -0.720 0.533 0.537
## BlockMinus 0.353 -0.260 -0.264 -0.255
## CndtnPIc:BM -0.237 0.248 0.171 0.161 -0.658
## CndtnPCn:BM -0.251 0.177 0.308 0.176 -0.698 0.497
## CndtPC-I:BM -0.240 0.166 0.175 0.296 -0.670 0.480 0.492
Exp1Agg <- aggregate(RespCorr ~ Condition + Block + ID , data=Exp1Data, mean, na.rm= FALSE)
Exp1Agg$Block <- factor(Exp1Agg$Block)
ggplot(data=Exp1Agg, aes(x=Block, y=RespCorr, group= Condition)) +
#geom_line(aes(color= Condition)) +
#geom_point(size=1.75, aes(colour = Condition)) +
geom_smooth(method='loess', formula= y ~ x, se= TRUE, aes(color = Condition, fill= Condition)) +
# scale_linetype_manual(values = c("solid", "solid", "solid",
# "longdash", "longdash", "longdash", "dotdash",
# "dotted")) +
scale_color_manual(values= c("#0066CC", "#CC0033","#33FF00", "#000000")) +
scale_fill_manual(values= c("#0066CC", "#CC0033","#33FF00", "#000000")) +
labs(x="Block", y="Proportion of Correct Responses") +
scale_y_continuous(limits = c(0.45,1), breaks=c(0.5,0.6,0.7,0.8,0.9,1.0)) +
theme_tufte() +
ggtitle("Comparison of Conditions of Experiment 1")
That’s purty ugly - lets output that with error bars or confidence intervals
#Calculate some crosstabs of successes for the condition x block interaction
#Crosstabs of number of trials
TrialsTable <- as.data.frame(xtabs(~Condition + Block, data= Exp1Data))
#Crosstables of correct responses
CorrectTable <- as.data.frame(xtabs(~Condition + Block, data= subset(Exp1Data, RespCorr == 1)))
#use summarySE to aggregate data getting mean, standard deviation, standard error, arnd 95% confidence intervals for the data
Exp1Agg2 <- summarySE(Exp1Data, measurevar= "RespCorr", groupvars = c("Condition", "Block"))
Exp1Agg2$Block <- factor(Exp1Agg2$Block)
pd <- position_dodge(width = 0.1)
#Plotting with 95% confidence interval
ggplot(data=Exp1Agg2, aes(x=Block, y=RespCorr, group= Condition)) +
geom_line(aes(color = Condition, linetype= Condition), size = 1.2, position=pd) +
geom_errorbar(aes(ymin= RespCorr - ci, ymax= RespCorr + ci, color= Condition), width= 0.2, size = 1, position=pd) +
geom_point(aes(color = Condition, shape = Condition), size = 3, position=pd) +
labs(x="Block", y="Proportion of Correct Responses") +
scale_y_continuous(limits = c(0.45,1), breaks=c(0.5,0.6,0.7,0.8,0.9,1.0)) +
theme_alan() +
scale_linetype_manual(values = c("solid", "solid", "longdash", "longdash")) +
scale_color_manual(values= c("#a1dab4", "#41b6c4","#2c7fb8", "#253494")) +
scale_shape_manual(values= c(15,16,17,18)) +
theme(legend.position = c(0.85, 0.22)) +
theme(legend.key=element_blank())
#+
#ggtitle("Comparison of Conditions of Experiment 1")
ggsave("Exp1Plot1.png", plot = last_plot(), device = NULL, path = NULL,
width = 8, height = 4.5, units = c("in", "cm", "mm"),
dpi = 600)
Heeeeey it’s finally pretty and has the variance plotted. Congratulations to me.
Lets move on to the early trials only
Exp1Early <- subset(Exp1Data, Trial <=8)
#Afex to replace model comparison
afex.Exp1Early <- mixed(RespCorr ~ Condition + (1|ID),
data=Exp1Early,
family=binomial,
control=glmerControl(optimizer="bobyqa"),
method = 'LRT',
progress=FALSE)
## Contrasts set to contr.sum for the following variables: Condition, ID
afex.Exp1Early$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: RespCorr ~ Condition + (1 | ID)
## Data: Exp1Early
## Df full model: 5
## Df Chisq Chi Df Pr(>Chisq)
## Condition 2 11.719 3 0.00841 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#full model gives coefficient to compare Iconic to all other levels
Exp1EarlyModel <- glmer(RespCorr ~ Condition + (1|ID), data=Exp1Early, family= "binomial", control=glmerControl(optimizer="bobyqa"))
summary(Exp1EarlyModel)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: RespCorr ~ Condition + (1 | ID)
## Data: Exp1Early
## Control: glmerControl(optimizer = "bobyqa")
##
## AIC BIC logLik deviance df.resid
## 661.8 682.9 -325.9 651.8 499
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.8359 -1.0456 0.5842 0.7977 1.0894
##
## Random effects:
## Groups Name Variance Std.Dev.
## ID (Intercept) 0.176 0.4195
## Number of obs: 504, groups: ID, 63
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.0689 0.2190 4.880 1.06e-06 ***
## ConditionConventional -0.8846 0.2981 -2.967 0.00301 **
## ConditionMixed Systematicity -0.9483 0.3186 -2.977 0.00292 **
## ConditionCounter-Iconic -0.4605 0.3107 -1.482 0.13834
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) CndtnC CndtMS
## CndtnCnvntn -0.732
## CndtnMxdSys -0.686 0.502
## CndtnCntr-I -0.695 0.510 0.477
#use Counter-Motivated as baseline. It's not better than Conventional, it's not worse than Motivated
Exp1Early$ConditionCM <- Exp1Early$Condition
Exp1Early$ConditionCM <- relevel(Exp1Early$ConditionCM,ref="Counter-Iconic")
Exp1EarlyModel2 <- glmer(RespCorr ~ ConditionCM + (1|ID), data=Exp1Early, family= "binomial", control=glmerControl(optimizer="bobyqa"))
summary(Exp1EarlyModel2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: RespCorr ~ ConditionCM + (1 | ID)
## Data: Exp1Early
## Control: glmerControl(optimizer = "bobyqa")
##
## AIC BIC logLik deviance df.resid
## 661.8 682.9 -325.9 651.8 499
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.8359 -1.0456 0.5842 0.7977 1.0894
##
## Random effects:
## Groups Name Variance Std.Dev.
## ID (Intercept) 0.176 0.4195
## Number of obs: 504, groups: ID, 63
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.6084 0.2234 2.724 0.00646 **
## ConditionCMIconic 0.4605 0.3107 1.482 0.13835
## ConditionCMConventional -0.4241 0.3016 -1.406 0.15966
## ConditionCMMixed Systematicity -0.4879 0.3218 -1.516 0.12948
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) CndCMI CndCMC
## CndtnCMIcnc -0.709
## CndtnCMCnvn -0.739 0.526
## CndtnCMMxdS -0.693 0.493 0.513
Now lets plot these earliest trials
#Summarize with confidence intervals and standarderror
Exp1EarlyAgg <- as.data.frame(summarySE(Exp1Early, measurevar= "RespCorr", groupvars = c("Condition", "ID")))
Exp1EarlyAgg
## Condition ID N RespCorr sd se
## 1 Iconic x1 8 0.875 0.3535534 0.1250000
## 2 Iconic x10 8 0.750 0.4629100 0.1636634
## 3 Iconic x2 8 0.625 0.5175492 0.1829813
## 4 Iconic x21 8 0.750 0.4629100 0.1636634
## 5 Iconic x22 8 0.750 0.4629100 0.1636634
## 6 Iconic X25 8 0.500 0.5345225 0.1889822
## 7 Iconic x3 8 0.875 0.3535534 0.1250000
## 8 Iconic x7 8 0.375 0.5175492 0.1829813
## 9 Iconic x8 8 0.875 0.3535534 0.1250000
## 10 Iconic x9 8 1.000 0.0000000 0.0000000
## 11 Iconic z10 8 1.000 0.0000000 0.0000000
## 12 Iconic z2 8 0.875 0.3535534 0.1250000
## 13 Iconic z4 8 0.875 0.3535534 0.1250000
## 14 Iconic z5 8 0.500 0.5345225 0.1889822
## 15 Iconic z6 8 0.625 0.5175492 0.1829813
## 16 Iconic z7 8 0.375 0.5175492 0.1829813
## 17 Iconic z8 8 0.875 0.3535534 0.1250000
## 18 Iconic z9 8 0.750 0.4629100 0.1636634
## 19 Conventional x11 8 0.750 0.4629100 0.1636634
## 20 Conventional x13 8 0.375 0.5175492 0.1829813
## 21 Conventional x14 8 0.500 0.5345225 0.1889822
## 22 Conventional x16 8 0.250 0.4629100 0.1636634
## 23 Conventional x17 8 0.625 0.5175492 0.1829813
## 24 Conventional x18 8 0.250 0.4629100 0.1636634
## 25 Conventional x19 8 0.625 0.5175492 0.1829813
## 26 Conventional x20 8 0.750 0.4629100 0.1636634
## 27 Conventional x23 8 0.375 0.5175492 0.1829813
## 28 Conventional Z1 8 0.625 0.5175492 0.1829813
## 29 Conventional z11 8 0.625 0.5175492 0.1829813
## 30 Conventional z12 8 0.500 0.5345225 0.1889822
## 31 Conventional z13 8 0.750 0.4629100 0.1636634
## 32 Conventional z14 8 0.375 0.5175492 0.1829813
## 33 Conventional z15 8 0.375 0.5175492 0.1829813
## 34 Conventional z16 8 0.875 0.3535534 0.1250000
## 35 Conventional z17 8 0.625 0.5175492 0.1829813
## 36 Mixed Systematicity 1 8 0.750 0.4629100 0.1636634
## 37 Mixed Systematicity 123 8 0.625 0.5175492 0.1829813
## 38 Mixed Systematicity 45920 8 0.625 0.5175492 0.1829813
## 39 Mixed Systematicity chimichurri 8 0.500 0.5345225 0.1889822
## 40 Mixed Systematicity Fon 8 0.500 0.5345225 0.1889822
## 41 Mixed Systematicity fr34 8 0.625 0.5175492 0.1829813
## 42 Mixed Systematicity g83 8 0.250 0.4629100 0.1636634
## 43 Mixed Systematicity s1151607 8 0.375 0.5175492 0.1829813
## 44 Mixed Systematicity s1422738 8 0.750 0.4629100 0.1636634
## 45 Mixed Systematicity s1444220 8 0.375 0.5175492 0.1829813
## 46 Mixed Systematicity s1447664 8 0.875 0.3535534 0.1250000
## 47 Mixed Systematicity s1470295 8 0.250 0.4629100 0.1636634
## 48 Mixed Systematicity yi79 8 0.375 0.5175492 0.1829813
## 49 Counter-Iconic C4Q1 8 0.750 0.4629100 0.1636634
## 50 Counter-Iconic C4Q10 8 0.500 0.5345225 0.1889822
## 51 Counter-Iconic C4Q11 8 0.875 0.3535534 0.1250000
## 52 Counter-Iconic C4Q12 8 0.375 0.5175492 0.1829813
## 53 Counter-Iconic C4Q13 8 0.875 0.3535534 0.1250000
## 54 Counter-Iconic C4Q14 8 0.750 0.4629100 0.1636634
## 55 Counter-Iconic c4q15 8 0.500 0.5345225 0.1889822
## 56 Counter-Iconic C4Q2 8 0.375 0.5175492 0.1829813
## 57 Counter-Iconic C4Q3 8 0.625 0.5175492 0.1829813
## 58 Counter-Iconic c4q4 8 0.875 0.3535534 0.1250000
## 59 Counter-Iconic C4Q5 8 0.750 0.4629100 0.1636634
## 60 Counter-Iconic C4Q6 8 0.375 0.5175492 0.1829813
## 61 Counter-Iconic C4Q7 8 0.500 0.5345225 0.1889822
## 62 Counter-Iconic c4q8 8 1.000 0.0000000 0.0000000
## 63 Counter-Iconic C4Q9 8 0.500 0.5345225 0.1889822
## ci
## 1 0.2955780
## 2 0.3870025
## 3 0.4326819
## 4 0.3870025
## 5 0.3870025
## 6 0.4468720
## 7 0.2955780
## 8 0.4326819
## 9 0.2955780
## 10 0.0000000
## 11 0.0000000
## 12 0.2955780
## 13 0.2955780
## 14 0.4468720
## 15 0.4326819
## 16 0.4326819
## 17 0.2955780
## 18 0.3870025
## 19 0.3870025
## 20 0.4326819
## 21 0.4468720
## 22 0.3870025
## 23 0.4326819
## 24 0.3870025
## 25 0.4326819
## 26 0.3870025
## 27 0.4326819
## 28 0.4326819
## 29 0.4326819
## 30 0.4468720
## 31 0.3870025
## 32 0.4326819
## 33 0.4326819
## 34 0.2955780
## 35 0.4326819
## 36 0.3870025
## 37 0.4326819
## 38 0.4326819
## 39 0.4468720
## 40 0.4468720
## 41 0.4326819
## 42 0.3870025
## 43 0.4326819
## 44 0.3870025
## 45 0.4326819
## 46 0.2955780
## 47 0.3870025
## 48 0.4326819
## 49 0.3870025
## 50 0.4468720
## 51 0.2955780
## 52 0.4326819
## 53 0.2955780
## 54 0.3870025
## 55 0.4468720
## 56 0.4326819
## 57 0.4326819
## 58 0.2955780
## 59 0.3870025
## 60 0.4326819
## 61 0.4468720
## 62 0.0000000
## 63 0.4468720
#And Plot (switching to a boxplot with jittered points by participant)
ggplot(data = Exp1EarlyAgg, aes(x= Condition, y= RespCorr)) +
geom_boxplot(aes(fill= Condition)) +
geom_jitter(width=0.25, height= 0) +
labs(x="", y="Proportion of Correct Responses") +
theme_alan() +
scale_fill_manual(values= c("#a1dab4", "#41b6c4","#2c7fb8", "#253494")) +
scale_y_continuous(limits = c(0,1), breaks = c(0,0.25,0.5,0.75,1)) +
theme(legend.position = c(0.85, 0.18))+
theme(legend.key=element_blank())
ggsave("Exp1Plot2.png", plot = last_plot(), device = NULL, path = NULL,
width = 8, height = 4.5, units = c("in", "cm", "mm"),
dpi = 600)
Definitely nicer than the previous dynamite plot
#log transform RTs
Exp1Data$LogRT <- log(Exp1Data$RT)
#Afex for main effects
afex.Exp1RT <- mixed(LogRT ~ Condition * BlockMinus + (1+BlockMinus|ID),
data=Exp1Data,
method = "LRT",
control = lmerControl(optCtrl = list(maxfun = 1e6)))
## Contrasts set to contr.sum for the following variables: Condition, ID
## Numerical variables NOT centered on 0: BlockMinus
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
## REML argument to lmer() set to FALSE for method = 'PB' or 'LRT'
## Fitting 4 (g)lmer() models:
## [....]
afex.Exp1RT$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: LogRT ~ Condition * BlockMinus + (1 + BlockMinus | ID)
## Data: Exp1Data
## Df full model: 12
## Df Chisq Chi Df Pr(>Chisq)
## Condition 9 13.1889 3 0.004245 **
## BlockMinus 11 76.2918 1 < 2.2e-16 ***
## Condition:BlockMinus 9 4.2578 3 0.234939
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Normal model for comparison of levels
Exp1RT <- lmer(LogRT ~ Condition * BlockMinus + (1 +BlockMinus|ID), data=Exp1Data)
summary(Exp1RT)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: LogRT ~ Condition * BlockMinus + (1 + BlockMinus | ID)
## Data: Exp1Data
##
## REML criterion at convergence: 5487.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8573 -0.6342 -0.1122 0.5263 6.9546
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ID (Intercept) 0.061753 0.24850
## BlockMinus 0.007493 0.08656 -0.48
## Residual 0.136955 0.37007
## Number of obs: 6048, groups: ID, 63
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 7.67377 0.06024 58.99997
## ConditionConventional -0.06789 0.08644 58.99997
## ConditionMixed Systematicity 0.13381 0.09302 58.99997
## ConditionCounter-Iconic 0.24008 0.08935 58.99997
## BlockMinus -0.18503 0.02313 59.00002
## ConditionConventional:BlockMinus 0.03230 0.03319 59.00002
## ConditionMixed Systematicity:BlockMinus 0.06413 0.03572 59.00002
## ConditionCounter-Iconic:BlockMinus 0.05588 0.03431 59.00002
## t value Pr(>|t|)
## (Intercept) 127.387 < 2e-16 ***
## ConditionConventional -0.785 0.43536
## ConditionMixed Systematicity 1.438 0.15559
## ConditionCounter-Iconic 2.687 0.00935 **
## BlockMinus -7.998 5.5e-11 ***
## ConditionConventional:BlockMinus 0.973 0.33447
## ConditionMixed Systematicity:BlockMinus 1.795 0.07776 .
## ConditionCounter-Iconic:BlockMinus 1.629 0.10874
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) CndtnC CndtMS CndC-I BlckMn CnC:BM CMS:BM
## CndtnCnvntn -0.697
## CndtnMxdSys -0.648 0.451
## CndtnCntr-I -0.674 0.470 0.437
## BlockMinus -0.496 0.346 0.321 0.334
## CndtnCnv:BM 0.346 -0.496 -0.224 -0.233 -0.697
## CndtnMSy:BM 0.321 -0.224 -0.496 -0.217 -0.648 0.451
## CndtnC-I:BM 0.334 -0.233 -0.217 -0.496 -0.674 0.470 0.437
Exp1RTAgg <- summarySE(Exp1Data, measurevar= "RT", groupvars = c("Condition", "Block"))
Exp1RTAgg$Block <- factor(Exp1RTAgg$Block)
pd <- position_dodge(width = 0.1)
#Plotting with 95% confidence interval
ggplot(data=Exp1RTAgg, aes(x=Block, y=RT, group= Condition)) +
geom_line(aes(color = Condition, linetype= Condition), size = 1.2, position=pd) +
geom_errorbar(aes(ymin= RT - ci, ymax= RT + ci, color= Condition), width= 0.2, size = 1, position=pd) +
geom_point(aes(color = Condition, shape = Condition), size = 3, position=pd) +
labs(x="Block", y="Response Time (ms)") +
scale_y_continuous(limits = c(1500,3600), breaks=c(1500,2000,2500,3000,3500)) +
theme_alan() +
scale_linetype_manual(values = c("solid", "solid", "longdash", "longdash")) +
scale_color_manual(values= c("#a1dab4", "#41b6c4","#2c7fb8", "#253494")) +
scale_shape_manual(values= c(15,16,17,18)) +
theme(legend.position = c(0.85, 0.8)) +
theme(legend.key=element_blank())
ggsave("Exp1Plot3.png", plot = last_plot(), device = NULL, path = NULL,
width = 8, height = 4.5, units = c("in", "cm", "mm"),
dpi = 600)
#summarise RTs
Exp1RTAgg2 <- summarySE(Exp1Data, measurevar= "RT", groupvars = c("Condition", "Block", "ID"))
#Summarise correctness
Exp1Agg2 <- summarySE(Exp1Data, measurevar= "RespCorr", groupvars = c("Condition", "Block", "ID"))
#Bind together and rename columns
Exp1Comp <- cbind(Exp1RTAgg2, Exp1Agg2)
colnames(Exp1Comp) <- c("Condition", "Block", "ID", "N", "RT", "sdRT", "seRT", "ciRT", "Condition2", "Block2", "ID2", "N2", "RespCorr", "sdRespCorr", "seRespCorr", "ciRespCorr")
#Plot that
ggplot(data=Exp1Comp, aes(x=RespCorr, y=RT, group= Condition)) +
geom_smooth(method = lm, se= FALSE, aes(color = Condition, linetype= Condition), size = 1.2) +
geom_point(aes(color = Condition, shape = Condition), size = 2) +
labs(x="Proportion of Correct Responses", y="Response Time (ms)") +
# scale_y_continuous(limits = c(1500,3600), breaks=c(1500,2000,2500,3000,3500)) +
theme_alan() +
scale_linetype_manual(values = c("solid", "solid", "longdash", "longdash")) +
scale_color_manual(values= c("#a1dab4", "#41b6c4","#2c7fb8", "#253494")) +
scale_shape_manual(values= c(15,16,17,18)) +
theme(legend.position = c(0.85, 0.8)) +
theme(legend.key=element_blank())
This doesn’t end up showing us a ton and won’t be included, but the slope of the Iconic vs. Counter-Iconic line tells us (broadly) that even participants who are better at the task are slower.
Exp2Data <- read.csv("C:/Users/Alan/Google Drive/Publications/Motivated vs Conventional Systematicity/Exp5.csv")
#convert these to factors
Exp2Data$Condition <- as.factor(Exp2Data$Condition)
Exp2Data$Trial.Type <- as.factor(Exp2Data$Trial.Type)
#Change Condition to a more transparent label - trial type 1 currently has "" as the level of the Relevant.Feature factor
Exp2Data$Condition<-revalue(Exp2Data$Condition, c("1"="Size Iconic - Shape Iconic", "2"="Size Conventional - Shape Conventional","3"="Size Iconic - Shape Conventional","4"="Size Conventional - Shape Iconic"))
#want to relevel these for the plots, to put Conventional-Conventional first
Exp2Data$Condition <- relevel(Exp2Data$Condition,ref="Size Conventional - Shape Conventional")
#More descriptive labels here are useful
Exp2Data$Consonants<-revalue(Exp2Data$Consonants, c("CS"="ConventionalConsonants","SS"="IconicConsonants"))
Exp2Data$Vowels<-revalue(Exp2Data$Vowels, c("CS"="ConventionalVowels","SS"="IconicVowels"))
#want the intercept to be performance on block 0
Exp2Data$BlockMinus <- Exp2Data$Block-1
Exp2Data$Trial.Type<-revalue(Exp2Data$Trial.Type, c("1"="Both Different", "2"="Size Different","3"="Shape Different"))
#log RTs for the RT analysis
Exp2Data$logRT <- log(Exp2Data$RT)
#Need these numeric versions for model comparison - I am setting them here so I know how to interpret the effects
#I am setting these up so that iconic = 1, i.e. the effects will be showing the effect of iconicity
Exp2Data$Vowels.numeric <- sapply(Exp2Data$Vowels,function(i) ifelse(i=="IconicVowels",1,0))
Exp2Data$Consonants.numeric <- sapply(Exp2Data$Consonants,function(i) ifelse(i=="IconicConsonants",1,0))
We will start with the by-trial-type analysis
afex.Exp2Both <- mixed(Correct~Consonants.numeric * Vowels.numeric * BlockMinus + (1 + BlockMinus |ID),
data=subset(Exp2Data, Trial.Type== "Both Different"),
family=binomial,
control=glmerControl(optimizer="bobyqa"),
method = 'LRT',
progress=FALSE)
## Contrasts set to contr.sum for the following variables: ID
## Numerical variables NOT centered on 0: Consonants.numeric, Vowels.numeric, BlockMinus
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
#Main Effects
afex.Exp2Both$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: Correct ~ Consonants.numeric * Vowels.numeric * BlockMinus +
## Model: (1 + BlockMinus | ID)
## Data: subset
## Data: Exp2Data
## Data: Trial.Type == "Both Different"
## Df full model: 11
## Df Chisq Chi Df Pr(>Chisq)
## Consonants.numeric 10 0.0575 1 0.810436
## Vowels.numeric 10 1.5464 1 0.213668
## BlockMinus 10 8.2996 1 0.003965
## Consonants.numeric:Vowels.numeric 10 1.6051 1 0.205178
## Consonants.numeric:BlockMinus 10 2.2702 1 0.131885
## Vowels.numeric:BlockMinus 10 0.1005 1 0.751191
## Consonants.numeric:Vowels.numeric:BlockMinus 10 0.0026 1 0.959590
##
## Consonants.numeric
## Vowels.numeric
## BlockMinus **
## Consonants.numeric:Vowels.numeric
## Consonants.numeric:BlockMinus
## Vowels.numeric:BlockMinus
## Consonants.numeric:Vowels.numeric:BlockMinus
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Comparisons
summary(afex.Exp2Both)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Correct ~ Consonants.numeric * Vowels.numeric * BlockMinus +
## (1 + BlockMinus | ID)
## Data: data
## Control: glmerControl(optimizer = "bobyqa")
##
## AIC BIC logLik deviance df.resid
## 2488.4 2555.8 -1233.2 2466.4 3373
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -10.4349 0.1290 0.2590 0.4448 1.1406
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ID (Intercept) 0.7618 0.8728
## BlockMinus 0.2370 0.4868 0.52
## Number of obs: 3384, groups: ID, 47
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.53863 0.29395 5.234
## Consonants.numeric 0.10022 0.41666 0.241
## Vowels.numeric -0.55024 0.43775 -1.257
## BlockMinus 0.59579 0.20275 2.939
## Consonants.numeric:Vowels.numeric 0.76583 0.59995 1.276
## Consonants.numeric:BlockMinus 0.45887 0.29977 1.531
## Vowels.numeric:BlockMinus -0.09131 0.28812 -0.317
## Consonants.numeric:Vowels.numeric:BlockMinus -0.02337 0.42094 -0.056
## Pr(>|z|)
## (Intercept) 1.66e-07 ***
## Consonants.numeric 0.8099
## Vowels.numeric 0.2088
## BlockMinus 0.0033 **
## Consonants.numeric:Vowels.numeric 0.2018
## Consonants.numeric:BlockMinus 0.1258
## Vowels.numeric:BlockMinus 0.7513
## Consonants.numeric:Vowels.numeric:BlockMinus 0.9557
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cnsnn. Vwls.n BlckMn Cn.:V. Cn.:BM Vw.:BM
## Cnsnnts.nmr -0.696
## Vowels.nmrc -0.668 0.467
## BlockMinus 0.075 -0.067 -0.055
## Cnsnnts.:V. 0.491 -0.693 -0.731 0.036
## Cnsnnts.:BM -0.070 0.082 0.045 -0.625 -0.061
## Vwls.nmr:BM -0.058 0.046 0.133 -0.690 -0.095 0.447
## Cnsn.:V.:BM 0.034 -0.059 -0.089 0.482 0.096 -0.692 -0.688
#Aggregating and Plotting
BothAgg1 <- summarySE(subset(Exp2Data, Trial.Type== "Both Different"), measurevar= "Correct", groupvars = c("Condition", "Block"))
BothAgg1$Block <- factor(BothAgg1$Block)
pd <- position_dodge(width = 0.1)
#Plotting with 95% confidence interval
ggplot(data=BothAgg1, aes(x=Block, y=Correct, group= Condition)) +
geom_line(aes(color = Condition, linetype= Condition), size = 1.2, position=pd) +
geom_errorbar(aes(ymin= Correct - ci, ymax= Correct + ci, color= Condition), width= 0.2, size = 1, position=pd) +
geom_point(aes(color = Condition, shape = Condition), size = 3, position=pd) +
labs(x="Block", y="Proportion of Correct Responses") +
scale_y_continuous(limits = c(0.45,1), breaks=c(0.5,0.6,0.7,0.8,0.9,1.0)) +
theme_alan() +
scale_linetype_manual(values = c("longdash", "solid", "longdash", "solid")) +
scale_color_manual(values= c("#a1dab4", "#253494","#253494", "#a1dab4")) +
scale_shape_manual(values= c(15,16,17,18)) +
theme(legend.position = c(0.75, 0.22)) +
theme(legend.key=element_blank())
ggsave("Exp2Both.png", plot = last_plot(), device = NULL, path = NULL,
width = 8, height = 5, units = c("in", "cm", "mm"),
dpi = 600)
afex.Exp2Shape <- mixed(Correct~Consonants.numeric * Vowels.numeric * BlockMinus + (1 + BlockMinus |ID),
data=subset(Exp2Data, Trial.Type== "Shape Different"),
family=binomial,
control=glmerControl(optimizer="bobyqa"),
method = 'LRT',
progress=FALSE)
## Contrasts set to contr.sum for the following variables: ID
## Numerical variables NOT centered on 0: Consonants.numeric, Vowels.numeric, BlockMinus
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
#Main Effects
afex.Exp2Shape$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: Correct ~ Consonants.numeric * Vowels.numeric * BlockMinus +
## Model: (1 + BlockMinus | ID)
## Data: subset
## Data: Exp2Data
## Data: Trial.Type == "Shape Different"
## Df full model: 11
## Df Chisq Chi Df Pr(>Chisq)
## Consonants.numeric 10 0.3813 1 0.5368825
## Vowels.numeric 10 0.0910 1 0.7628962
## BlockMinus 10 15.1305 1 0.0001003
## Consonants.numeric:Vowels.numeric 10 0.3206 1 0.5712445
## Consonants.numeric:BlockMinus 10 0.2713 1 0.6024626
## Vowels.numeric:BlockMinus 10 3.5867 1 0.0582437
## Consonants.numeric:Vowels.numeric:BlockMinus 10 0.6120 1 0.4340197
##
## Consonants.numeric
## Vowels.numeric
## BlockMinus ***
## Consonants.numeric:Vowels.numeric
## Consonants.numeric:BlockMinus
## Vowels.numeric:BlockMinus .
## Consonants.numeric:Vowels.numeric:BlockMinus
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Comparisons
summary(afex.Exp2Shape)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Correct ~ Consonants.numeric * Vowels.numeric * BlockMinus +
## (1 + BlockMinus | ID)
## Data: data
## Control: glmerControl(optimizer = "bobyqa")
##
## AIC BIC logLik deviance df.resid
## 2135.3 2200.7 -1056.7 2113.3 2809
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -9.5395 0.1147 0.2664 0.4350 1.1331
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ID (Intercept) 0.8569 0.9257
## BlockMinus 0.2345 0.4843 0.72
## Number of obs: 2820, groups: ID, 47
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.3018 0.3122 4.169
## Consonants.numeric 0.2753 0.4422 0.623
## Vowels.numeric -0.1417 0.4680 -0.303
## BlockMinus 0.8905 0.2211 4.028
## Consonants.numeric:Vowels.numeric 0.3631 0.6397 0.568
## Consonants.numeric:BlockMinus 0.1638 0.3116 0.526
## Vowels.numeric:BlockMinus -0.5847 0.3031 -1.929
## Consonants.numeric:Vowels.numeric:BlockMinus 0.3429 0.4330 0.792
## Pr(>|z|)
## (Intercept) 3.06e-05 ***
## Consonants.numeric 0.5335
## Vowels.numeric 0.7621
## BlockMinus 5.63e-05 ***
## Consonants.numeric:Vowels.numeric 0.5703
## Consonants.numeric:BlockMinus 0.5991
## Vowels.numeric:BlockMinus 0.0537 .
## Consonants.numeric:Vowels.numeric:BlockMinus 0.4284
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cnsnn. Vwls.n BlckMn Cn.:V. Cn.:BM Vw.:BM
## Cnsnnts.nmr -0.697
## Vowels.nmrc -0.661 0.464
## BlockMinus 0.169 -0.135 -0.124
## Cnsnnts.:V. 0.489 -0.691 -0.733 0.082
## Cnsnnts.:BM -0.139 0.188 0.095 -0.641 -0.131
## Vwls.nmr:BM -0.132 0.100 0.235 -0.705 -0.168 0.469
## Cnsn.:V.:BM 0.088 -0.133 -0.164 0.506 0.199 -0.712 -0.705
#Aggregating and Plotting
ShapeAgg1 <- summarySE(subset(Exp2Data, Trial.Type== "Shape Different"), measurevar= "Correct", groupvars = c("Condition", "Block"))
ShapeAgg1$Block <- factor(ShapeAgg1$Block)
pd <- position_dodge(width = 0.1)
#Plotting with 95% confidence interval
ggplot(data=ShapeAgg1, aes(x=Block, y=Correct, group= Condition)) +
geom_line(aes(color = Condition, linetype= Condition), size = 1.2, position=pd) +
geom_errorbar(aes(ymin= Correct - ci, ymax= Correct + ci, color= Condition), width= 0.2, size = 1, position=pd) +
geom_point(aes(color = Condition, shape = Condition), size = 3, position=pd) +
labs(x="Block", y="Proportion of Correct Responses") +
scale_y_continuous(limits = c(0.45,1), breaks=c(0.5,0.6,0.7,0.8,0.9,1.0)) +
theme_alan() +
scale_linetype_manual(values = c("longdash", "solid", "longdash", "solid")) +
scale_color_manual(values= c("#a1dab4", "#253494","#253494", "#a1dab4")) +
scale_shape_manual(values= c(15,16,17,18)) +
theme(legend.position = c(0.75, 0.22)) +
theme(legend.key=element_blank())
ggsave("Exp2Shape.png", plot = last_plot(), device = NULL, path = NULL,
width = 8, height = 5, units = c("in", "cm", "mm"),
dpi = 600)
afex.Exp2Size <- mixed(Correct~Consonants.numeric * Vowels.numeric * BlockMinus + (1 + BlockMinus |ID),
data=subset(Exp2Data, Trial.Type== "Size Different"),
family=binomial,
control=glmerControl(optimizer="bobyqa"),
method = 'LRT',
progress=FALSE)
## Contrasts set to contr.sum for the following variables: ID
## Numerical variables NOT centered on 0: Consonants.numeric, Vowels.numeric, BlockMinus
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
#Main Effects
afex.Exp2Size$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: Correct ~ Consonants.numeric * Vowels.numeric * BlockMinus +
## Model: (1 + BlockMinus | ID)
## Data: subset
## Data: Exp2Data
## Data: Trial.Type == "Size Different"
## Df full model: 11
## Df Chisq Chi Df Pr(>Chisq)
## Consonants.numeric 10 0.5582 1 0.4549752
## Vowels.numeric 10 2.0290 1 0.1543217
## BlockMinus 10 13.2894 1 0.0002669
## Consonants.numeric:Vowels.numeric 10 0.0506 1 0.8220840
## Consonants.numeric:BlockMinus 10 6.4275 1 0.0112368
## Vowels.numeric:BlockMinus 10 1.1209 1 0.2897230
## Consonants.numeric:Vowels.numeric:BlockMinus 10 7.8745 1 0.0050137
##
## Consonants.numeric
## Vowels.numeric
## BlockMinus ***
## Consonants.numeric:Vowels.numeric
## Consonants.numeric:BlockMinus *
## Vowels.numeric:BlockMinus
## Consonants.numeric:Vowels.numeric:BlockMinus **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Comparisons
summary(afex.Exp2Size)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Correct ~ Consonants.numeric * Vowels.numeric * BlockMinus +
## (1 + BlockMinus | ID)
## Data: data
## Control: glmerControl(optimizer = "bobyqa")
##
## AIC BIC logLik deviance df.resid
## 3460.0 3525.4 -1719.0 3438.0 2809
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.5451 -1.0060 0.4450 0.8014 1.3036
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ID (Intercept) 0.36285 0.6024
## BlockMinus 0.04502 0.2122 0.55
## Number of obs: 2820, groups: ID, 47
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 0.02707 0.21249 0.127
## Consonants.numeric 0.22524 0.30023 0.750
## Vowels.numeric 0.47006 0.32787 1.434
## BlockMinus 0.45841 0.11735 3.906
## Consonants.numeric:Vowels.numeric -0.09893 0.43964 -0.225
## Consonants.numeric:BlockMinus -0.42981 0.16278 -2.640
## Vowels.numeric:BlockMinus -0.19421 0.18132 -1.071
## Consonants.numeric:Vowels.numeric:BlockMinus 0.71827 0.24579 2.922
## Pr(>|z|)
## (Intercept) 0.89862
## Consonants.numeric 0.45311
## Vowels.numeric 0.15166
## BlockMinus 9.38e-05 ***
## Consonants.numeric:Vowels.numeric 0.82197
## Consonants.numeric:BlockMinus 0.00828 **
## Vowels.numeric:BlockMinus 0.28413
## Consonants.numeric:Vowels.numeric:BlockMinus 0.00347 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cnsnn. Vwls.n BlckMn Cn.:V. Cn.:BM Vw.:BM
## Cnsnnts.nmr -0.708
## Vowels.nmrc -0.647 0.459
## BlockMinus -0.128 0.090 0.081
## Cnsnnts.:V. 0.483 -0.683 -0.744 -0.062
## Cnsnnts.:BM 0.092 -0.126 -0.059 -0.719 0.086
## Vwls.nmr:BM 0.081 -0.058 -0.137 -0.638 0.100 0.461
## Cnsn.:V.:BM -0.062 0.083 0.099 0.480 -0.140 -0.664 -0.731
#Aggregating and Plotting
SizeAgg1 <- summarySE(subset(Exp2Data, Trial.Type== "Size Different"), measurevar= "Correct", groupvars = c("Condition", "Block"))
SizeAgg1$Block <- factor(SizeAgg1$Block)
pd <- position_dodge(width = 0.1)
#Plotting with 95% confidence interval
ggplot(data=SizeAgg1, aes(x=Block, y=Correct, group= Condition)) +
geom_line(aes(color = Condition, linetype= Condition), size = 1.2, position=pd) +
geom_errorbar(aes(ymin= Correct - ci, ymax= Correct + ci, color= Condition), width= 0.2, size = 1, position=pd) +
geom_point(aes(color = Condition, shape = Condition), size = 3, position=pd) +
labs(x="Block", y="Proportion of Correct Responses") +
scale_y_continuous(limits = c(0.4,1.04), breaks=c(0.4, 0.5,0.6,0.7,0.8,0.9,1.0)) +
theme_alan() +
scale_linetype_manual(values = c("longdash", "solid", "longdash", "solid")) +
scale_color_manual(values= c("#a1dab4", "#253494","#253494", "#a1dab4")) +
scale_shape_manual(values= c(15,16,17,18)) +
theme(legend.position = c(0.75, 0.82)) +
theme(legend.key=element_blank())
ggsave("Exp2Size.png", plot = last_plot(), device = NULL, path = NULL,
width = 8, height = 5, units = c("in", "cm", "mm"),
dpi = 600)
The above analyses and graphs are found in the appendix - for the main body of the experiment we conduct an omnibus analysis where the data is collapsed to allow us to explore the interference effect
#Recoding
#1 if the relevant feature is encoded iconically, 0 if not
classify.relevant.feature <- function(trial.type,consonants,vowels) {
if (trial.type=="Both Different") {
if (consonants=="IconicConsonants" | vowels=="IconicVowels") {
1}
else {0}}
else if (trial.type=="Shape Different") {
if (consonants=="IconicConsonants") {
1
}
else {0}
}
else if (trial.type=="Size Different") {
if (vowels=="IconicVowels") {
1
}
else {0}
}
}
#1 if the relevant feature is encoded iconically, 0 if not, and NA if there are no irrelevant features
classify.irrelevant.feature <- function(trial.type,consonants,vowels) {
if (trial.type=="Both Different") {
NA
}
else if (trial.type=="Shape Different") {
if (vowels=="IconicVowels") {
1
}
else {0}
}
else if (trial.type=="Size Different") {
if (consonants=="IconicConsonants") {
1
}
else {0}
}
}
Exp2Data$RelevantFeatureIsIconic <- mapply(function(trial.type,consonants,vowels) classify.relevant.feature(trial.type,consonants,vowels),Exp2Data$Trial.Type,Exp2Data$Consonants,Exp2Data$Vowels)
Exp2Data$IrrelevantFeatureIsIconic <- mapply(function(trial.type,consonants,vowels) classify.irrelevant.feature(trial.type,consonants,vowels),Exp2Data$Trial.Type,Exp2Data$Consonants,Exp2Data$Vowels)
#Omnibus Model
afex.Exp2Omnibus <- mixed(Correct ~ RelevantFeatureIsIconic * IrrelevantFeatureIsIconic * BlockMinus +
(1 + BlockMinus * RelevantFeatureIsIconic * IrrelevantFeatureIsIconic |ID),
data=subset(Exp2Data,!is.na(IrrelevantFeatureIsIconic)),
family=binomial,
control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=20000)),
method = 'LRT')
## Contrasts set to contr.sum for the following variables: ID
## Numerical variables NOT centered on 0: RelevantFeatureIsIconic, IrrelevantFeatureIsIconic, BlockMinus
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
## Fitting 8 (g)lmer() models:
## [
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge: degenerate Hessian with 2 negative
## eigenvalues
## .
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge: degenerate Hessian with 2 negative
## eigenvalues
## ...
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge: degenerate Hessian with 3 negative
## eigenvalues
## .
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge: degenerate Hessian with 2 negative
## eigenvalues
## .
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge: degenerate Hessian with 2 negative
## eigenvalues
## .
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge: degenerate Hessian with 2 negative
## eigenvalues
## .]
afex.Exp2Omnibus$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: Correct ~ RelevantFeatureIsIconic * IrrelevantFeatureIsIconic *
## Model: BlockMinus + (1 + BlockMinus * RelevantFeatureIsIconic *
## Model: IrrelevantFeatureIsIconic | ID)
## Data: subset
## Data: Exp2Data
## Data: !is.na(IrrelevantFeatureIsIconic)
## Df full model: 44
## Df Chisq
## RelevantFeatureIsIconic 43 3.4530
## IrrelevantFeatureIsIconic 43 0.0803
## BlockMinus 43 14.8178
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 43 0.0818
## RelevantFeatureIsIconic:BlockMinus 43 1.5610
## IrrelevantFeatureIsIconic:BlockMinus 43 7.7555
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 43 0.3490
## Chi Df
## RelevantFeatureIsIconic 1
## IrrelevantFeatureIsIconic 1
## BlockMinus 1
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 1
## RelevantFeatureIsIconic:BlockMinus 1
## IrrelevantFeatureIsIconic:BlockMinus 1
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 1
## Pr(>Chisq)
## RelevantFeatureIsIconic 0.0631367
## IrrelevantFeatureIsIconic 0.7768718
## BlockMinus 0.0001184
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.7749016
## RelevantFeatureIsIconic:BlockMinus 0.2115209
## IrrelevantFeatureIsIconic:BlockMinus 0.0053549
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.5546806
##
## RelevantFeatureIsIconic .
## IrrelevantFeatureIsIconic
## BlockMinus ***
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic
## RelevantFeatureIsIconic:BlockMinus
## IrrelevantFeatureIsIconic:BlockMinus **
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(afex.Exp2Omnibus)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Correct ~ RelevantFeatureIsIconic * IrrelevantFeatureIsIconic *
## BlockMinus + (1 + BlockMinus * RelevantFeatureIsIconic *
## IrrelevantFeatureIsIconic | ID)
## Data: data
## Control:
## glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 20000))
##
## AIC BIC logLik deviance df.resid
## 5914.4 6206.5 -2913.2 5826.4 5596
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -6.3313 -0.9035 0.3905 0.6310 1.2634
##
## Random effects:
## Groups Name
## ID (Intercept)
## BlockMinus
## RelevantFeatureIsIconic
## IrrelevantFeatureIsIconic
## BlockMinus:RelevantFeatureIsIconic
## BlockMinus:IrrelevantFeatureIsIconic
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic
## BlockMinus:RelevantFeatureIsIconic:IrrelevantFeatureIsIconic
## Variance Std.Dev. Corr
## 0.24256 0.4925
## 0.03705 0.1925 1.00
## 0.67340 0.8206 -0.04 -0.04
## 0.45324 0.6732 -0.44 -0.44 -0.42
## 0.22948 0.4790 0.21 0.21 0.96 -0.43
## 0.05319 0.2306 -0.76 -0.76 -0.41 0.90 -0.54
## 0.47707 0.6907 -0.04 -0.04 -0.32 -0.23 -0.37 -0.06
## 0.11772 0.3431 -0.21 -0.21 -0.73 0.20 -0.80 0.36 0.84
## Number of obs: 5640, groups: ID, 47
##
## Fixed effects:
## Estimate
## (Intercept) 0.55931
## RelevantFeatureIsIconic 0.54719
## IrrelevantFeatureIsIconic 0.06819
## BlockMinus 0.48975
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic -0.10806
## RelevantFeatureIsIconic:BlockMinus 0.25639
## IrrelevantFeatureIsIconic:BlockMinus -0.37764
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.15715
## Std. Error
## (Intercept) 0.16884
## RelevantFeatureIsIconic 0.29149
## IrrelevantFeatureIsIconic 0.24025
## BlockMinus 0.09840
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.37661
## RelevantFeatureIsIconic:BlockMinus 0.21463
## IrrelevantFeatureIsIconic:BlockMinus 0.13129
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.25041
## z value
## (Intercept) 3.313
## RelevantFeatureIsIconic 1.877
## IrrelevantFeatureIsIconic 0.284
## BlockMinus 4.977
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic -0.287
## RelevantFeatureIsIconic:BlockMinus 1.195
## IrrelevantFeatureIsIconic:BlockMinus -2.876
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.628
## Pr(>|z|)
## (Intercept) 0.000924 ***
## RelevantFeatureIsIconic 0.060485 .
## IrrelevantFeatureIsIconic 0.776534
## BlockMinus 6.46e-07 ***
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.774164
## RelevantFeatureIsIconic:BlockMinus 0.232247
## IrrelevantFeatureIsIconic:BlockMinus 0.004023 **
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.530286
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) RlvFII IrrFII BlckMn RlFII:IFII RFII:B IFII:B
## RlvntFtrIsI -0.579
## IrrlvntFtII -0.703 0.304
## BlockMinus 0.162 -0.093 -0.114
## RlvFII:IFII 0.448 -0.708 -0.558 0.072
## RlvntFII:BM -0.074 0.289 0.005 -0.458 -0.194
## IrrlvFII:BM -0.121 -0.025 0.033 -0.749 0.052 0.282
## RFII:IFII:B 0.063 -0.198 0.023 0.393 0.168 -0.825 -0.471
## convergence code: 0
## unable to evaluate scaled gradient
## Model failed to converge: degenerate Hessian with 2 negative eigenvalues
#Omnibus Model (Simplified random effects structure- Now Converges)
afex.Exp2Omnibus2 <- mixed(Correct ~ RelevantFeatureIsIconic * IrrelevantFeatureIsIconic * BlockMinus +
(1 + BlockMinus |ID),
data=subset(Exp2Data,!is.na(IrrelevantFeatureIsIconic)),
family=binomial,
control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=20000)),
method = 'LRT')
## Contrasts set to contr.sum for the following variables: ID
## Numerical variables NOT centered on 0: RelevantFeatureIsIconic, IrrelevantFeatureIsIconic, BlockMinus
## If in interactions, interpretation of lower order (e.g., main) effects difficult.
## Fitting 8 (g)lmer() models:
## [........]
afex.Exp2Omnibus2$anova_table
## Mixed Model Anova Table (Type 3 tests, LRT-method)
##
## Model: Correct ~ RelevantFeatureIsIconic * IrrelevantFeatureIsIconic *
## Model: BlockMinus + (1 + BlockMinus | ID)
## Data: subset
## Data: Exp2Data
## Data: !is.na(IrrelevantFeatureIsIconic)
## Df full model: 11
## Df Chisq
## RelevantFeatureIsIconic 10 2.9875
## IrrelevantFeatureIsIconic 10 0.0255
## BlockMinus 10 23.1787
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 10 0.0130
## RelevantFeatureIsIconic:BlockMinus 10 0.4965
## IrrelevantFeatureIsIconic:BlockMinus 10 8.7783
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 10 6.5975
## Chi Df
## RelevantFeatureIsIconic 1
## IrrelevantFeatureIsIconic 1
## BlockMinus 1
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 1
## RelevantFeatureIsIconic:BlockMinus 1
## IrrelevantFeatureIsIconic:BlockMinus 1
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 1
## Pr(>Chisq)
## RelevantFeatureIsIconic 0.083911
## IrrelevantFeatureIsIconic 0.873056
## BlockMinus 1.476e-06
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.909351
## RelevantFeatureIsIconic:BlockMinus 0.481063
## IrrelevantFeatureIsIconic:BlockMinus 0.003048
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.010212
##
## RelevantFeatureIsIconic .
## IrrelevantFeatureIsIconic
## BlockMinus ***
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic
## RelevantFeatureIsIconic:BlockMinus
## IrrelevantFeatureIsIconic:BlockMinus **
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(afex.Exp2Omnibus2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Correct ~ RelevantFeatureIsIconic * IrrelevantFeatureIsIconic *
## BlockMinus + (1 + BlockMinus | ID)
## Data: data
## Control:
## glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 20000))
##
## AIC BIC logLik deviance df.resid
## 6058.4 6131.4 -3018.2 6036.4 5629
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -5.8084 -0.9172 0.4410 0.6401 1.1339
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ID (Intercept) 0.2870 0.5358
## BlockMinus 0.0325 0.1803 1.00
## Number of obs: 5640, groups: ID, 47
##
## Fixed effects:
## Estimate
## (Intercept) 0.56320
## RelevantFeatureIsIconic 0.41563
## IrrelevantFeatureIsIconic 0.03743
## BlockMinus 0.48566
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.04196
## RelevantFeatureIsIconic:BlockMinus -0.09394
## IrrelevantFeatureIsIconic:BlockMinus -0.38276
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.50046
## Std. Error
## (Intercept) 0.17920
## RelevantFeatureIsIconic 0.23699
## IrrelevantFeatureIsIconic 0.23387
## BlockMinus 0.09406
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.36790
## RelevantFeatureIsIconic:BlockMinus 0.13289
## IrrelevantFeatureIsIconic:BlockMinus 0.12586
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.19310
## z value
## (Intercept) 3.143
## RelevantFeatureIsIconic 1.754
## IrrelevantFeatureIsIconic 0.160
## BlockMinus 5.163
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.114
## RelevantFeatureIsIconic:BlockMinus -0.707
## IrrelevantFeatureIsIconic:BlockMinus -3.041
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 2.592
## Pr(>|z|)
## (Intercept) 0.00167 **
## RelevantFeatureIsIconic 0.07947 .
## IrrelevantFeatureIsIconic 0.87285
## BlockMinus 2.42e-07 ***
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic 0.90920
## RelevantFeatureIsIconic:BlockMinus 0.47964
## IrrelevantFeatureIsIconic:BlockMinus 0.00236 **
## RelevantFeatureIsIconic:IrrelevantFeatureIsIconic:BlockMinus 0.00955 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) RlvFII IrrFII BlckMn RlFII:IFII RFII:B IFII:B
## RlvntFtrIsI -0.754
## IrrlvntFtII -0.765 0.825
## BlockMinus 0.179 -0.140 -0.140
## RlvFII:IFII 0.486 -0.801 -0.795 0.086
## RlvntFII:BM -0.130 0.042 0.249 -0.695 -0.122
## IrrlvFII:BM -0.136 0.260 0.079 -0.737 -0.150 0.614
## RFII:IFII:B 0.086 -0.131 -0.154 0.491 0.164 -0.751 -0.720