Main statistical Analyses
Children
Run a model with main with factors with two levels given centered numeric coding, and for the 3 level factor consistency use sequential constrasts comparing Fully Consistent to Partially Consistent and then Partially Consistent to Inconsistent.
Note, this is done using a handcoded function - it could also be done using the than MASS::contr.sdiff(3) (we checked and the results are the same). This handed coded function makes it easier for us to break down main effects and interactions within the same model.
Note that in this coding, the contrast Partial_v_Inconsistent is coded so that +ve means that inconsistent is greater than partial- this is flipped for the reporting so that it matches the direction of the prediction.
prodOLDchild <- droplevels(subset(prod1, oldnew=="old" & age == "Child"))
prodOLDchild = lizCenter(prodOLDchild, list("typefreq", "session"))
## creates versions of these factors with centered coding
prodOLDchild = setContrasts(prodOLDchild, prodOLDchild$consistency, "Partial")
## adds Partial_VS_Consistent+Partial_VS_Inconsistent constrasts
prodOLDchild.lmer = glmer(det_correct ~ (Partial_VS_Consistent+Partial_VS_Inconsistent) * typefreq.ct * session.ct + (1 + session.ct|participant), data = prodOLDchild, family = binomial, control = glmerControl(optimizer = "bobyqa"))
jtools::summ(prodOLDchild.lmer, digits = 3)
## MODEL INFO:
## Observations: 4908
## Dependent Variable: det_correct
## Type: Mixed effects generalized linear regression
## Error Distribution: binomial
## Link function: logit
##
## MODEL FIT:
## AIC = 5779.201, BIC = 5876.680
## Pseudo-R² (fixed effects) = 0.112
## Pseudo-R² (total) = 0.265
##
## FIXED EFFECTS:
## ---------------------------------------------------------------------
## Est. S.E.
## ---------------------------------------------------- -------- -------
## (Intercept) 0.909 0.090
## Partial_VS_Consistent 0.666 0.219
## Partial_VS_Inconsistent -0.090 0.212
## typefreq.ct -0.291 0.176
## session.ct 1.115 0.106
## Partial_VS_Consistent:typefreq.ct -0.324 0.434
## Partial_VS_Inconsistent:typefreq.ct -0.361 0.423
## Partial_VS_Consistent:session.ct 0.898 0.255
## Partial_VS_Inconsistent:session.ct 0.036 0.239
## typefreq.ct:session.ct -0.371 0.204
## Partial_VS_Consistent:typefreq.ct:session.ct -0.616 0.502
## Partial_VS_Inconsistent:typefreq.ct:session.ct -0.974 0.477
## ---------------------------------------------------------------------
##
## ---------------------------------------------------------------------
## z val. p
## ---------------------------------------------------- -------- -------
## (Intercept) 10.133 0.000
## Partial_VS_Consistent 3.048 0.002
## Partial_VS_Inconsistent -0.427 0.669
## typefreq.ct -1.650 0.099
## session.ct 10.498 0.000
## Partial_VS_Consistent:typefreq.ct -0.746 0.455
## Partial_VS_Inconsistent:typefreq.ct -0.854 0.393
## Partial_VS_Consistent:session.ct 3.516 0.000
## Partial_VS_Inconsistent:session.ct 0.153 0.879
## typefreq.ct:session.ct -1.819 0.069
## Partial_VS_Consistent:typefreq.ct:session.ct -1.226 0.220
## Partial_VS_Inconsistent:typefreq.ct:session.ct -2.044 0.041
## ---------------------------------------------------------------------
##
## RANDOM EFFECTS:
## ---------------------------------------
## Group Parameter Std. Dev.
## ------------- ------------- -----------
## participant (Intercept) 0.755
## participant session.ct 0.685
## ---------------------------------------
##
## Grouping variables:
## --------------------------------
## Group # groups ICC
## ------------- ---------- -------
## participant 90 0.148
## --------------------------------
There is an effect of session in the first model. We now check whether performance is above chance in both sessions.
# First get means for each session
summarySEwithin(data = prodOLDchild, "det_correct", betweenvars = NULL, withinvars = "session", idvar = "participant", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## session N det_correct det_correct_norm sd se
## 1 1 2171 0.5660986 0.5717909 0.6866936 0.01473781
## 2 4 2737 0.7493606 0.7448455 0.5745576 0.01098237
## ci
## 1 0.02890171
## 2 0.02153458
# re-run model, removing overall intercept + effect of session and replcing with two separate intercepts, one for each session
prodOLDchild.lmer1a = glmer(det_correct ~ + session + (Partial_VS_Consistent+Partial_VS_Inconsistent) * typefreq.ct * session.ct -1 - session.ct + (1 + session.ct|participant), data = prodOLDchild, family = binomial, control = glmerControl(optimizer = "bobyqa"))
#demonstrate this is the same model as before
anova(prodOLDchild.lmer, prodOLDchild.lmer1a)
## Data: prodOLDchild
## Models:
## prodOLDchild.lmer: det_correct ~ (Partial_VS_Consistent + Partial_VS_Inconsistent) *
## prodOLDchild.lmer: typefreq.ct * session.ct + (1 + session.ct | participant)
## prodOLDchild.lmer1a: det_correct ~ +session + (Partial_VS_Consistent + Partial_VS_Inconsistent) *
## prodOLDchild.lmer1a: typefreq.ct * session.ct - 1 - session.ct + (1 + session.ct |
## prodOLDchild.lmer1a: participant)
## Df AIC BIC logLik deviance Chisq Chi Df
## prodOLDchild.lmer 15 5779.2 5876.7 -2874.6 5749.2
## prodOLDchild.lmer1a 15 5779.2 5876.7 -2874.6 5749.2 0 0
## Pr(>Chisq)
## prodOLDchild.lmer
## prodOLDchild.lmer1a < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# print out the coefficients for the two intercepts
get_coeffs(prodOLDchild.lmer1a, c("session1", "session4"))
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| session1 | 0.287 | 0.065 | 4.391 | 0 |
| session4 | 1.403 | 0.127 | 11.077 | 0 |
More accurate in partial than inconsistent - look at the means:
summarySE(data = prodOLDchild, "det_correct", groupvars = "consistency", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## consistency N det_correct sd se ci
## 1 Consistent 1638 0.7295482 0.4443289 0.01097862 0.02153361
## 2 Inconsistent 1580 0.6265823 0.4838648 0.01217294 0.02387682
## 3 Partial 1690 0.6479290 0.4777573 0.01162155 0.02279415
There is an interaction between the partial versus consistent contrast and the effect of session. Check whether there is an effect of this contrast in each of the two sessions
# First get means for each session
summarySEwithin(data = prodOLDchild, "det_correct", betweenvars = "consistency", withinvars = "session", idvar = "participant", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## consistency session N det_correct det_correct_norm sd
## 1 Consistent 1 731 0.5909713 0.5388601 0.6588449
## 2 Consistent 4 907 0.8412348 0.7726166 0.4914255
## 3 Inconsistent 1 668 0.5344311 0.5868609 0.7120325
## 4 Inconsistent 4 912 0.6940789 0.7279447 0.6130383
## 5 Partial 1 772 0.5699482 0.5899328 0.6888249
## 6 Partial 4 918 0.7135076 0.7341974 0.6088264
## se ci
## 1 0.02436826 0.04784023
## 2 0.01631752 0.03202452
## 3 0.02754937 0.05409392
## 4 0.02029973 0.03983966
## 5 0.02479135 0.04866655
## 6 0.02009427 0.03943609
# re-run model, removing overall contrast of Partial vs consistent averaged across sessions and interaction between this and session, and replacing with effect of contrast for each level of session
prodOLDchild.lmer1b = glmer(det_correct ~ + Partial_VS_Consistent:session + (Partial_VS_Consistent+Partial_VS_Inconsistent) * typefreq.ct * session.ct -Partial_VS_Consistent - Partial_VS_Consistent:session.ct + (1 + session.ct|participant), data = prodOLDchild, family = binomial, control = glmerControl(optimizer = "bobyqa"))
# check it is the same model
anova(prodOLDchild.lmer, prodOLDchild.lmer1b)
## Data: prodOLDchild
## Models:
## prodOLDchild.lmer: det_correct ~ (Partial_VS_Consistent + Partial_VS_Inconsistent) *
## prodOLDchild.lmer: typefreq.ct * session.ct + (1 + session.ct | participant)
## prodOLDchild.lmer1b: det_correct ~ +Partial_VS_Consistent:session + (Partial_VS_Consistent +
## prodOLDchild.lmer1b: Partial_VS_Inconsistent) * typefreq.ct * session.ct - Partial_VS_Consistent -
## prodOLDchild.lmer1b: Partial_VS_Consistent:session.ct + (1 + session.ct | participant)
## Df AIC BIC logLik deviance Chisq Chi Df
## prodOLDchild.lmer 15 5779.2 5876.7 -2874.6 5749.2
## prodOLDchild.lmer1b 15 5779.2 5876.7 -2874.6 5749.2 0 0
## Pr(>Chisq)
## prodOLDchild.lmer
## prodOLDchild.lmer1b < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# print out the coefficients for the effect of Partial vs consistent at each level of session
get_coeffs(prodOLDchild.lmer1b, c("Partial_VS_Consistent:session1", "Partial_VS_Consistent:session4"))
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| Partial_VS_Consistent:session1 | 0.165 | 0.159 | 1.038 | 0.299 |
| Partial_VS_Consistent:session4 | 1.063 | 0.308 | 3.457 | 0.001 |
Adults
Run a model with main with factors with two levels given centered numeric coding, and for the 3 level factor consistency use sequential constrasts comparing Fully Consistent to Partially Consistent and then Partially Consistent to Inconsistent.
Note, this is done using a handcoded function - it could also be done using the than MASS::contr.sdiff(3) (we checked and the results are the same). This handed coded function makes it easier for us to break down main effects and interactions within the same model.
Note that in this coding, the contrast Partial_v_Inconsistent is coded so that +ve means that inconsistent is greater than partial- this is flipped for the reporting so that it matches the direction of the prediction.
prodOLDadult <- droplevels(subset(prodADULT, oldnew=="old"))
prodOLDadult <- lizCenter(prodOLDadult, list("typefreq", "session"))
# creates versions of these factors with centered coding
prodOLDadult = setContrasts(prodOLDadult, prodOLDadult$consistency, "Partial")
## adds columns for the contrasts Partial_VS_Consistent and Partial_VS_Inconsistent
prodOLDadult.lmer = glmer(det_correct ~ (Partial_VS_Consistent+Partial_VS_Inconsistent) * typefreq.ct * session.ct + (1 + session.ct|participant),data = prodOLDadult, family = binomial, control = glmerControl(optimizer = "bobyqa"))
jtools::summ(prodOLDadult.lmer, digits = 3)
## MODEL INFO:
## Observations: 3728
## Dependent Variable: det_correct
## Type: Mixed effects generalized linear regression
## Error Distribution: binomial
## Link function: logit
##
## MODEL FIT:
## AIC = 2082.140, BIC = 2175.494
## Pseudo-R² (fixed effects) = 0.360
## Pseudo-R² (total) = 0.727
##
## FIXED EFFECTS:
## ---------------------------------------------------------------------
## Est. S.E.
## ---------------------------------------------------- -------- -------
## (Intercept) 3.843 0.380
## Partial_VS_Consistent 2.460 0.761
## Partial_VS_Inconsistent 0.290 0.666
## typefreq.ct -1.193 0.586
## session.ct 3.123 0.626
## Partial_VS_Consistent:typefreq.ct -0.413 1.516
## Partial_VS_Inconsistent:typefreq.ct -1.355 1.327
## Partial_VS_Consistent:session.ct 0.997 1.102
## Partial_VS_Inconsistent:session.ct 1.409 0.858
## typefreq.ct:session.ct 0.709 0.800
## Partial_VS_Consistent:typefreq.ct:session.ct 2.140 2.142
## Partial_VS_Inconsistent:typefreq.ct:session.ct -1.214 1.716
## ---------------------------------------------------------------------
##
## ---------------------------------------------------------------------
## z val. p
## ---------------------------------------------------- -------- -------
## (Intercept) 10.124 0.000
## Partial_VS_Consistent 3.232 0.001
## Partial_VS_Inconsistent 0.436 0.663
## typefreq.ct -2.037 0.042
## session.ct 4.992 0.000
## Partial_VS_Consistent:typefreq.ct -0.272 0.785
## Partial_VS_Inconsistent:typefreq.ct -1.021 0.307
## Partial_VS_Consistent:session.ct 0.904 0.366
## Partial_VS_Inconsistent:session.ct 1.643 0.100
## typefreq.ct:session.ct 0.885 0.376
## Partial_VS_Consistent:typefreq.ct:session.ct 0.999 0.318
## Partial_VS_Inconsistent:typefreq.ct:session.ct -0.708 0.479
## ---------------------------------------------------------------------
##
## RANDOM EFFECTS:
## ---------------------------------------
## Group Parameter Std. Dev.
## ------------- ------------- -----------
## participant (Intercept) 1.853
## participant session.ct 2.002
## ---------------------------------------
##
## Grouping variables:
## --------------------------------
## Group # groups ICC
## ------------- ---------- -------
## participant 60 0.511
## --------------------------------
There is an effect of session in the first model. We now check whether performance is above chance in both sessions.
# First get means for each session
summarySEwithin(data = prodOLDadult, "det_correct", betweenvars = NULL, withinvars = "session", idvar = "participant", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## session N det_correct det_correct_norm sd se
## 1 1 1815 0.8126722 0.8129596 0.5012923 0.011766647
## 2 4 1913 0.9409305 0.9406577 0.3101091 0.007090175
## ci
## 1 0.02307760
## 2 0.01390529
# re-run model, removing overall intercept + effect of session and replcing with two separate intercepts, one for each session
prodOLDadult.lmer2c = glmer(det_correct ~ - 1 + session + (Partial_VS_Consistent+Partial_VS_Inconsistent)* typefreq.ct * session.ct - session.ct + (1 + session.ct|participant), data = prodOLDadult, family = binomial, control = glmerControl(optimizer = "bobyqa"))
# check it is the same model as above
anova(prodOLDadult.lmer, prodOLDadult.lmer2c)
## Data: prodOLDadult
## Models:
## prodOLDadult.lmer: det_correct ~ (Partial_VS_Consistent + Partial_VS_Inconsistent) *
## prodOLDadult.lmer: typefreq.ct * session.ct + (1 + session.ct | participant)
## prodOLDadult.lmer2c: det_correct ~ -1 + session + (Partial_VS_Consistent + Partial_VS_Inconsistent) *
## prodOLDadult.lmer2c: typefreq.ct * session.ct - session.ct + (1 + session.ct |
## prodOLDadult.lmer2c: participant)
## Df AIC BIC logLik deviance Chisq Chi Df
## prodOLDadult.lmer 15 2082.1 2175.5 -1026.1 2052.1
## prodOLDadult.lmer2c 15 2082.1 2175.5 -1026.1 2052.1 0 0
## Pr(>Chisq)
## prodOLDadult.lmer
## prodOLDadult.lmer2c 1
#print out coefficients for each session
get_coeffs(prodOLDadult.lmer2c, c("session1", "session4"))
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| session1 | 2.240 | 0.214 | 10.485 | 0 |
| session4 | 5.363 | 0.655 | 8.193 | 0 |
# means for each level of type frequency
summarySEwithin(data = prodOLDadult, "det_correct", betweenvars = NULL, withinvars = "typefreq", idvar = "participant", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## typefreq N det_correct det_correct_norm sd se
## 1 High 1883 0.8343070 0.8784871 0.4900711 0.011293639
## 2 Low 1845 0.9235772 0.8784871 0.3439084 0.008006535
## ci
## 1 0.02214937
## 2 0.01570283
# means for each level of type frequency
summarySEwithin(data = prodOLDadult, "det_correct", betweenvars = NULL, withinvars = "typefreq", idvar = "participant", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## typefreq N det_correct det_correct_norm sd se
## 1 High 1883 0.8343070 0.8784871 0.4900711 0.011293639
## 2 Low 1845 0.9235772 0.8784871 0.3439084 0.008006535
## ci
## 1 0.02214937
## 2 0.01570283
More accurate in partial than inconsistent - look at the means:
summarySE(data = prodOLDadult, "det_correct", groupvars = "consistency", na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
## consistency N det_correct sd se ci
## 1 Consistent 1253 0.9449322 0.2282037 0.006446844 0.01264781
## 2 Inconsistent 1274 0.8343799 0.3718852 0.010418957 0.02044021
## 3 Partial 1201 0.8559534 0.3512833 0.010136452 0.01988714
Comparing children and adults
An omnibus model comparing children and adults- coding as above
prodOLDboth <- droplevels(subset(prod1, oldnew=="old"))
prodOLDboth <- lizCenter(prodOLDboth, list("typefreq", "session", "age"))
# creates versions of these factors with centered coding
prodOLDboth = setContrasts(prodOLDboth, prodOLDboth$consistency, "Partial")
## adds columns for the contrasts Partial_VS_Consistent and Partial_VS_Inconsistent
prodOLDboth.lmer = glmer(det_correct ~ (Partial_VS_Consistent + Partial_VS_Inconsistent) * typefreq.ct * session.ct * age.ct + (1 + session.ct|participant), data = prodOLDboth, family = binomial, control = glmerControl(optimizer = "bobyqa"))
jtools::summ(prodOLDboth.lmer, digits = 3)
## MODEL INFO:
## Observations: 8636
## Dependent Variable: det_correct
## Type: Mixed effects generalized linear regression
## Error Distribution: binomial
## Link function: logit
##
## MODEL FIT:
## AIC = 7895.511, BIC = 8086.231
## Pseudo-R² (fixed effects) = 0.372
## Pseudo-R² (total) = 0.563
##
## FIXED EFFECTS:
## --------------------------------------------------------------------
## Est.
## ----------------------------------------------------------- --------
## (Intercept) 1.959
## Partial_VS_Consistent 1.328
## Partial_VS_Inconsistent 0.052
## typefreq.ct -0.660
## session.ct 1.671
## age.ct 2.348
## Partial_VS_Consistent:typefreq.ct -0.571
## Partial_VS_Inconsistent:typefreq.ct -0.698
## Partial_VS_Consistent:session.ct 0.907
## Partial_VS_Inconsistent:session.ct 0.543
## typefreq.ct:session.ct 0.115
## Partial_VS_Consistent:age.ct 1.342
## Partial_VS_Inconsistent:age.ct 0.313
## typefreq.ct:age.ct -0.763
## session.ct:age.ct 1.144
## Partial_VS_Consistent:typefreq.ct:session.ct 0.358
## Partial_VS_Inconsistent:typefreq.ct:session.ct -0.946
## Partial_VS_Consistent:typefreq.ct:age.ct -0.435
## Partial_VS_Inconsistent:typefreq.ct:age.ct -0.776
## Partial_VS_Consistent:session.ct:age.ct -0.147
## Partial_VS_Inconsistent:session.ct:age.ct 1.181
## typefreq.ct:session.ct:age.ct 1.195
## Partial_VS_Consistent:typefreq.ct:session.ct:age.ct 2.497
## Partial_VS_Inconsistent:typefreq.ct:session.ct:age.ct 0.200
## --------------------------------------------------------------------
##
## -------------------------------------------------------------------
## S.E.
## ----------------------------------------------------------- -------
## (Intercept) 0.118
## Partial_VS_Consistent 0.274
## Partial_VS_Inconsistent 0.246
## typefreq.ct 0.215
## session.ct 0.159
## age.ct 0.237
## Partial_VS_Consistent:typefreq.ct 0.539
## Partial_VS_Inconsistent:typefreq.ct 0.492
## Partial_VS_Consistent:session.ct 0.346
## Partial_VS_Inconsistent:session.ct 0.272
## typefreq.ct:session.ct 0.261
## Partial_VS_Consistent:age.ct 0.567
## Partial_VS_Inconsistent:age.ct 0.509
## typefreq.ct:age.ct 0.451
## session.ct:age.ct 0.312
## Partial_VS_Consistent:typefreq.ct:session.ct 0.670
## Partial_VS_Inconsistent:typefreq.ct:session.ct 0.544
## Partial_VS_Consistent:typefreq.ct:age.ct 1.128
## Partial_VS_Inconsistent:typefreq.ct:age.ct 1.007
## Partial_VS_Consistent:session.ct:age.ct 0.728
## Partial_VS_Inconsistent:session.ct:age.ct 0.574
## typefreq.ct:session.ct:age.ct 0.564
## Partial_VS_Consistent:typefreq.ct:session.ct:age.ct 1.465
## Partial_VS_Inconsistent:typefreq.ct:session.ct:age.ct 1.138
## -------------------------------------------------------------------
##
## ----------------------------------------------------------------------------
## z val. p
## ----------------------------------------------------------- -------- -------
## (Intercept) 16.602 0.000
## Partial_VS_Consistent 4.853 0.000
## Partial_VS_Inconsistent 0.210 0.834
## typefreq.ct -3.068 0.002
## session.ct 10.481 0.000
## age.ct 9.924 0.000
## Partial_VS_Consistent:typefreq.ct -1.061 0.289
## Partial_VS_Inconsistent:typefreq.ct -1.419 0.156
## Partial_VS_Consistent:session.ct 2.623 0.009
## Partial_VS_Inconsistent:session.ct 1.998 0.046
## typefreq.ct:session.ct 0.441 0.659
## Partial_VS_Consistent:age.ct 2.366 0.018
## Partial_VS_Inconsistent:age.ct 0.615 0.538
## typefreq.ct:age.ct -1.693 0.090
## session.ct:age.ct 3.673 0.000
## Partial_VS_Consistent:typefreq.ct:session.ct 0.535 0.593
## Partial_VS_Inconsistent:typefreq.ct:session.ct -1.740 0.082
## Partial_VS_Consistent:typefreq.ct:age.ct -0.385 0.700
## Partial_VS_Inconsistent:typefreq.ct:age.ct -0.771 0.441
## Partial_VS_Consistent:session.ct:age.ct -0.201 0.840
## Partial_VS_Inconsistent:session.ct:age.ct 2.056 0.040
## typefreq.ct:session.ct:age.ct 2.117 0.034
## Partial_VS_Consistent:typefreq.ct:session.ct:age.ct 1.705 0.088
## Partial_VS_Inconsistent:typefreq.ct:session.ct:age.ct 0.175 0.861
## ----------------------------------------------------------------------------
##
## RANDOM EFFECTS:
## ---------------------------------------
## Group Parameter Std. Dev.
## ------------- ------------- -----------
## participant (Intercept) 1.101
## participant session.ct 0.951
## ---------------------------------------
##
## Grouping variables:
## --------------------------------
## Group # groups ICC
## ------------- ---------- -------
## participant 150 0.269
## --------------------------------