rm(list=ls())
source("../../analysis/final/useful.R")
## Loading required package: Matrix
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
##
## Loading required package: quadprog
library(pander)
library(magrittr)
library(tidyr)
##
## Attaching package: 'tidyr'
##
## The following object is masked from 'package:magrittr':
##
## extract
##
## The following object is masked from 'package:Matrix':
##
## expand
df_expt1 <- read.csv("soc-xsit-expt1-finalData.csv")
m1_acc_expt1 <- glmer(
correct ~ (trialType + condition + log2(intervalNum + 1) + log2(numPicN))^2 - 1 +
(trialType | subids), control=glmerControl(optimizer="bobyqa"),
data=filter(df_expt1, trial_category == "test", include_good_rt_test == "include",
correct_exposure == T | condition == "No-Social"),
family=binomial, nAGQ=0)
knitr::kable(summary(m1_acc_expt1)$coef, digits = 2)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| trialTypeSame | 4.16 | 0.20 | 20.39 | 0.00 |
| trialTypeSwitch | 2.58 | 0.14 | 18.08 | 0.00 |
| conditionSocial | -0.47 | 0.21 | -2.19 | 0.03 |
| log2(intervalNum + 1) | -0.59 | 0.08 | -7.34 | 0.00 |
| log2(numPicN) | -0.68 | 0.08 | -8.36 | 0.00 |
| trialTypeSwitch:conditionSocial | -0.55 | 0.10 | -5.45 | 0.00 |
| trialTypeSwitch:log2(intervalNum + 1) | 0.52 | 0.04 | 11.93 | 0.00 |
| trialTypeSwitch:log2(numPicN) | -0.62 | 0.06 | -9.67 | 0.00 |
| conditionSocial:log2(intervalNum + 1) | 0.08 | 0.05 | 1.53 | 0.13 |
| conditionSocial:log2(numPicN) | 0.16 | 0.08 | 2.00 | 0.05 |
| log2(intervalNum + 1):log2(numPicN) | 0.00 | 0.03 | -0.05 | 0.96 |
The critical two-way interaction between gaze condition and trial type is significant. We interpret this as the difference between gaze and no-gaze is larger with worse performance on switch trials.
m2_acc_expt1 <- glmer(
correct ~ (trialType + condition + log2(intervalNum + 1) + log2(numPicN))^3 - 1 +
(trialType | subids),
data=filter(df_expt1, trial_category == "test", include_good_rt_test == "include",
correct_exposure == T | condition == "No-Social"),
family=binomial, nAGQ=0)
knitr::kable(summary(m2_acc_expt1)$coef, digits = 2)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| trialTypeSame | 3.96 | 0.28 | 13.92 | 0.00 |
| trialTypeSwitch | 2.73 | 0.16 | 16.78 | 0.00 |
| conditionSocial | -0.65 | 0.43 | -1.51 | 0.13 |
| log2(intervalNum + 1) | -0.46 | 0.13 | -3.47 | 0.00 |
| log2(numPicN) | -0.64 | 0.12 | -5.35 | 0.00 |
| trialTypeSwitch:conditionSocial | -0.68 | 0.37 | -1.85 | 0.06 |
| trialTypeSwitch:log2(intervalNum + 1) | 0.28 | 0.13 | 2.08 | 0.04 |
| trialTypeSwitch:log2(numPicN) | -0.72 | 0.12 | -5.77 | 0.00 |
| conditionSocial:log2(intervalNum + 1) | 0.09 | 0.18 | 0.53 | 0.60 |
| conditionSocial:log2(numPicN) | 0.40 | 0.18 | 2.23 | 0.03 |
| log2(intervalNum + 1):log2(numPicN) | -0.03 | 0.06 | -0.58 | 0.56 |
| trialTypeSwitch:conditionSocial:log2(intervalNum + 1) | 0.24 | 0.09 | 2.55 | 0.01 |
| trialTypeSwitch:conditionSocial:log2(numPicN) | -0.14 | 0.15 | -0.93 | 0.35 |
| trialTypeSwitch:log2(intervalNum + 1):log2(numPicN) | 0.07 | 0.06 | 1.29 | 0.20 |
| conditionSocial:log2(intervalNum + 1):log2(numPicN) | -0.10 | 0.07 | -1.33 | 0.18 |
Here the two-way interaction between gaze and switch trial is marginally signifcant, and there is three-way interaction between switch trials, gaze condition, and interval.
anova(m1_acc_expt1, m2_acc_expt1)
## Data: filter(df_expt1, trial_category == "test", include_good_rt_test == ...
## Models:
## m1_acc_expt1: correct ~ (trialType + condition + log2(intervalNum + 1) + log2(numPicN))^2 -
## m1_acc_expt1: 1 + (trialType | subids)
## m2_acc_expt1: correct ~ (trialType + condition + log2(intervalNum + 1) + log2(numPicN))^3 -
## m2_acc_expt1: 1 + (trialType | subids)
## Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
## m1_acc_expt1 14 17402 17510 -8686.7 17374
## m2_acc_expt1 18 17396 17535 -8679.7 17360 14.04 4 0.007167 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
3 way model is much better than the 2 way model based on likelihood ratio test.
Here we remove participants who did not reliably use gaze on exposure trials and fit the 3-way interactions model.
m1_acc_expt1_filt <- glmer(
correct ~ (trialType + condition + log2(intervalNum + 1) + log2(numPicN))^3 - 1 +
(trialType | subids),
data=filter(df_expt1, trial_category == "test",
include_good_rt_test == "include",
include_expo == "include" | condition == "No-Social",
correct_exposure == T | condition == "No-Social"),
family=binomial, nAGQ=0)
knitr::kable(summary(m1_acc_expt1_filt)$coef, digits = 2)
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| trialTypeSame | 3.97 | 0.29 | 13.91 | 0.00 |
| trialTypeSwitch | 2.72 | 0.16 | 16.75 | 0.00 |
| conditionSocial | -0.70 | 0.44 | -1.57 | 0.12 |
| log2(intervalNum + 1) | -0.46 | 0.13 | -3.50 | 0.00 |
| log2(numPicN) | -0.65 | 0.12 | -5.37 | 0.00 |
| trialTypeSwitch:conditionSocial | -0.80 | 0.38 | -2.10 | 0.04 |
| trialTypeSwitch:log2(intervalNum + 1) | 0.29 | 0.14 | 2.12 | 0.03 |
| trialTypeSwitch:log2(numPicN) | -0.71 | 0.13 | -5.70 | 0.00 |
| conditionSocial:log2(intervalNum + 1) | 0.13 | 0.18 | 0.73 | 0.46 |
| conditionSocial:log2(numPicN) | 0.44 | 0.18 | 2.37 | 0.02 |
| log2(intervalNum + 1):log2(numPicN) | -0.03 | 0.06 | -0.54 | 0.59 |
| trialTypeSwitch:conditionSocial:log2(intervalNum + 1) | 0.25 | 0.10 | 2.66 | 0.01 |
| trialTypeSwitch:conditionSocial:log2(numPicN) | -0.11 | 0.15 | -0.72 | 0.47 |
| trialTypeSwitch:log2(intervalNum + 1):log2(numPicN) | 0.07 | 0.06 | 1.23 | 0.22 |
| conditionSocial:log2(intervalNum + 1):log2(numPicN) | -0.12 | 0.07 | -1.59 | 0.11 |
This narrows the confidence interval around the critical 2-way interaction and thus it is now significant.