EEG amplitude analyses
set working directory/ load in data/ add language group variable
setwd("C:/Users/Katie/Desktop/Research/Dissertation/STUDIES/Studies 3 and 4 EEG/L1 and L2 French/EEG Inaccurate removed/EEG data/")
list.files()
## [1] "kate-output-470baseline-ALL-every-ms.txt"
## [2] "kate-output-470baseline-ALL.txt"
## [3] "L1 and L2 acc-only eeg amplitude.Rmd"
## [4] "L1___L2_acc-only_eeg_amplitude.Rmd"
## [5] "L1_and_L2_acc-only_eeg_amplitude.html"
## [6] "L1_and_L2_acc-only_eeg_amplitude.Rmd"
## [7] "L2 acc-only eeg amplitude.Rmd"
## [8] "L2 offline data for R.csv"
## [9] "L2_acc-only_eeg_amplitude.html"
## [10] "rsconnect"
data<-read.table("kate-output-470baseline-ALL.txt",header=TRUE)
all.subs<-unique(data$subj)
L1.subj<-as.character(all.subs[32:61])
L2.subj<-as.character(all.subs[1:31])
lang.l1<-rep("L1",30)
L1<-cbind(L1.subj,lang.l1)
lang.l2<-rep("L2",31)
L2<-cbind(L2.subj,lang.l2)
colnames(L1)<-c("subj","lang")
colnames(L2)<-c("subj","lang")
subj.lang<-rbind(L1,L2)
library(qdap)
data$lang<-lookup(data$subj,subj.lang)
Add condition and relatedness to the dataframe
cond<-as.character(unique(data[,2]))
conditions<-c("id","id","morph","morph", "orth", "orth", "sem","sem")
match_cond<-cbind(cond,conditions)
relateds<-c("rel","unrel","rel","unrel", "rel", "unrel", "rel","unrel")
match_rel<-cbind(cond,relateds)
data$Condition<-lookup(data$cond,match_cond)
data$Related<-lookup(data$cond,match_rel)
data$Condition<-as.factor(as.character(data$Condition))
data$Related<-as.factor(as.character(data$Related))
data$lang<-as.factor(as.character(data$lang))
head(data,15)
## subj cond chan win mean lang Condition Related
## 1 KC101 fidr Fp1 +100..+301 3.40080 L2 id rel
## 2 KC101 fidr Fp1 +301..+500 -5.22830 L2 id rel
## 3 KC101 fidr Fp1 +500..+600 -7.72310 L2 id rel
## 4 KC101 fidr Fp1 +176..+275 2.36930 L2 id rel
## 5 KC101 fidr Fp1 +350..+449 -6.82230 L2 id rel
## 6 KC101 fidr Fp1 +449..+551 -6.84700 L2 id rel
## 7 KC101 fidr Fp2 +100..+301 7.03560 L2 id rel
## 8 KC101 fidr Fp2 +301..+500 -0.50613 L2 id rel
## 9 KC101 fidr Fp2 +500..+600 -1.84000 L2 id rel
## 10 KC101 fidr Fp2 +176..+275 6.40640 L2 id rel
## 11 KC101 fidr Fp2 +350..+449 -1.92650 L2 id rel
## 12 KC101 fidr Fp2 +449..+551 -1.96650 L2 id rel
## 13 KC101 fidr F3 +100..+301 5.96740 L2 id rel
## 14 KC101 fidr F3 +301..+500 -1.37510 L2 id rel
## 15 KC101 fidr F3 +500..+600 -0.25718 L2 id rel
Add factors of hemisphere (3 levels) and AntPos (3 levels) for 20 electrodes
electrodes<-as.character(unique(data$chan))
hems<-c("left","right","left","right","left","right","left","right","left","right","left","right","left","right","left","right","mid","mid","mid","mid")
el.hem<-cbind(electrodes,hems)
antpos<-c("ant","ant","ant","ant","central","central","post","post","ant","ant","central","central","post","post","post","post","ant","central","post","post")
el.antpost<-cbind(electrodes,antpos)
data$hemisphere<-lookup(data$chan,el.hem)
data$hemisphere<-as.factor(data$hemisphere)
data$antpos<-lookup(data$chan,el.antpost)
data$antpos<-as.factor(data$antpos)
Relevel to make the unrelated condition the baseline and make central the baseline for antpos and mid for hemisphere
data$Related<-relevel(data$Related,ref="unrel")
data$antpos<-relevel(data$antpos,ref="central")
data$hemisphere<-relevel(data$hemisphere,ref="mid")
Code hemisphere and antpos with sum coding instead of deviance coding
#contrasts(data$hemisphere)<-contr.sum(3,contrasts=FALSE)
#contrasts(data$antpos)<-contr.sum(3, contrasts=FALSE)
Remove participants
data<-data[data$subj!= "KC04" &data$subj!="KC15" &data$subj!="KC27" &data$subj!="KC107" &data$subj!="KC109" &data$subj!="KC110" &data$subj!="KC116" &data$subj!="KC125",]
create time windows
time100<-data[data$win=="+100..+301",]
time300<-data[data$win=="+301..+500",]
time500<-data[data$win=="+500..+600",]
time175<-data[data$win=="+176..+275",]
time350<-data[data$win=="+350..+449",]
time450<-data[data$win=="+449..+551",]
library(lme4)
library(lmerTest)
t1.1<-lmer(mean~Condition*Related*lang*hemisphere*antpos+(1|subj),time100)
#step(t1.1)
t1.final<-lmer(formula = mean ~ Condition + Related + lang + hemisphere +
antpos + (1 | subj) + Condition:Related + Condition:lang +
Related:lang + Related:hemisphere + lang:hemisphere + lang:antpos +
hemisphere:antpos + Condition:Related:lang, data = time100)
summary(t1.final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
## to degrees of freedom [lmerMod]
## Formula: mean ~ Condition + Related + lang + hemisphere + antpos + (1 |
## subj) + Condition:Related + Condition:lang + Related:lang +
## Related:hemisphere + lang:hemisphere + lang:antpos + hemisphere:antpos +
## Condition:Related:lang
## Data: time100
##
## REML criterion at convergence: 40167.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.4687 -0.5916 0.0241 0.6107 7.1607
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj (Intercept) 2.686 1.639
## Residual 6.476 2.545
## Number of obs: 8480, groups: subj, 53
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 1.54327 0.36636 90.00000 4.212
## Conditionmorph -0.24833 0.15487 8399.00000 -1.603
## Conditionorth -0.22576 0.15487 8399.00000 -1.458
## Conditionsem 0.11091 0.15487 8399.00000 0.716
## Relatedrel 0.60740 0.19027 8399.00000 3.192
## langL2 0.39344 0.49878 74.00000 0.789
## hemisphereleft 0.17008 0.18497 8399.00000 0.920
## hemisphereright -0.31655 0.18497 8399.00000 -1.711
## antposant 1.58851 0.18869 8399.00000 8.419
## antpospost -2.50318 0.16643 8399.00000 -15.040
## Conditionmorph:Relatedrel -0.03028 0.21902 8399.00000 -0.138
## Conditionorth:Relatedrel -0.33615 0.21902 8399.00000 -1.535
## Conditionsem:Relatedrel -0.98495 0.21902 8399.00000 -4.497
## Conditionmorph:langL2 0.65567 0.22111 8399.00000 2.965
## Conditionorth:langL2 0.06181 0.22111 8399.00000 0.280
## Conditionsem:langL2 -0.27891 0.22111 8399.00000 -1.261
## Relatedrel:langL2 0.66933 0.22111 8399.00000 3.027
## Relatedrel:hemisphereleft -0.31502 0.15136 8399.00000 -2.081
## Relatedrel:hemisphereright 0.03061 0.15136 8399.00000 0.202
## langL2:hemisphereleft -0.45887 0.15224 8399.00000 -3.014
## langL2:hemisphereright -0.05835 0.15224 8399.00000 -0.383
## langL2:antposant -0.26685 0.14497 8399.00000 -1.841
## langL2:antpospost 0.45722 0.14110 8399.00000 3.240
## hemisphereleft:antposant 0.35307 0.20802 8399.00000 1.697
## hemisphereright:antposant 0.76362 0.20802 8399.00000 3.671
## hemisphereleft:antpospost -1.36523 0.18878 8399.00000 -7.232
## hemisphereright:antpospost -1.24069 0.18878 8399.00000 -6.572
## Conditionmorph:Relatedrel:langL2 -1.33323 0.31270 8399.00000 -4.264
## Conditionorth:Relatedrel:langL2 -0.59841 0.31270 8399.00000 -1.914
## Conditionsem:Relatedrel:langL2 -0.29281 0.31270 8399.00000 -0.936
## Pr(>|t|)
## (Intercept) 5.98e-05 ***
## Conditionmorph 0.108865
## Conditionorth 0.144945
## Conditionsem 0.473922
## Relatedrel 0.001416 **
## langL2 0.432726
## hemisphereleft 0.357853
## hemisphereright 0.087056 .
## antposant < 2e-16 ***
## antpospost < 2e-16 ***
## Conditionmorph:Relatedrel 0.890047
## Conditionorth:Relatedrel 0.124870
## Conditionsem:Relatedrel 6.98e-06 ***
## Conditionmorph:langL2 0.003032 **
## Conditionorth:langL2 0.779852
## Conditionsem:langL2 0.207202
## Relatedrel:langL2 0.002477 **
## Relatedrel:hemisphereleft 0.037439 *
## Relatedrel:hemisphereright 0.839711
## langL2:hemisphereleft 0.002584 **
## langL2:hemisphereright 0.701537
## langL2:antposant 0.065697 .
## langL2:antpospost 0.001199 **
## hemisphereleft:antposant 0.089677 .
## hemisphereright:antposant 0.000243 ***
## hemisphereleft:antpospost 5.18e-13 ***
## hemisphereright:antpospost 5.25e-11 ***
## Conditionmorph:Relatedrel:langL2 2.03e-05 ***
## Conditionorth:Relatedrel:langL2 0.055692 .
## Conditionsem:Relatedrel:langL2 0.349098
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t1.final.anova<-lmerTest::anova(t1.final)
t1.final.anova
## Analysis of Variance Table of type III with Satterthwaite
## approximation for degrees of freedom
## Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
## Condition 456 151.9 3 8399.0 23.45 4.108e-15 ***
## Related 102 102.1 1 8399.0 15.77 7.222e-05 ***
## lang 6 6.4 1 51.2 0.98 0.3256923
## hemisphere 344 171.9 2 8399.0 26.54 3.223e-12 ***
## antpos 34972 17486.0 2 8399.0 2700.27 < 2.2e-16 ***
## Condition:Related 345 115.1 3 8399.0 17.78 1.682e-11 ***
## Condition:lang 66 21.9 3 8399.0 3.38 0.0174704 *
## Related:lang 7 6.8 1 8399.0 1.05 0.3058488
## Related:hemisphere 58 28.8 2 8399.0 4.44 0.0118176 *
## lang:hemisphere 90 45.2 2 8399.0 6.98 0.0009380 ***
## lang:antpos 210 105.1 2 8399.0 16.24 9.171e-08 ***
## hemisphere:antpos 949 237.3 4 8399.0 36.65 < 2.2e-16 ***
## Condition:Related:lang 130 43.5 3 8399.0 6.71 0.0001611 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lmer-output results of interest
Findings in 100-300 time window
t3.1<-lmer(mean~Condition*Related*lang*hemisphere*antpos+(1|subj),time300)
#step(t3.1)
t3.final<-lmer(formula = mean ~ Condition + Related + lang + hemisphere +
antpos + (1 | subj) + Condition:Related + Condition:lang +
Related:lang + lang:hemisphere + Related:antpos + lang:antpos +
hemisphere:antpos + Condition:Related:lang, data = time300)
summary(t3.final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
## to degrees of freedom [lmerMod]
## Formula: mean ~ Condition + Related + lang + hemisphere + antpos + (1 |
## subj) + Condition:Related + Condition:lang + Related:lang +
## lang:hemisphere + Related:antpos + lang:antpos + hemisphere:antpos +
## Condition:Related:lang
## Data: time300
##
## REML criterion at convergence: 42737.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -7.5664 -0.5504 0.0332 0.5838 7.0783
##
## Random effects:
## Groups Name Variance Std.Dev.
## subj (Intercept) 5.021 2.241
## Residual 8.760 2.960
## Number of obs: 8480, groups: subj, 53
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.27714 0.48158 78.00000 4.728
## Conditionmorph -0.22424 0.18012 8399.00000 -1.245
## Conditionorth -0.41552 0.18012 8399.00000 -2.307
## Conditionsem -0.31532 0.18012 8399.00000 -1.751
## Relatedrel 0.76031 0.21176 8399.00000 3.591
## langL2 -1.93217 0.66430 68.00000 -2.909
## hemisphereleft -0.02824 0.19630 8399.00000 -0.144
## hemisphereright 0.55316 0.19630 8399.00000 2.818
## antposant -0.30190 0.23504 8399.00000 -1.284
## antpospost 0.56461 0.21021 8399.00000 2.686
## Conditionmorph:Relatedrel 0.16309 0.25473 8399.00000 0.640
## Conditionorth:Relatedrel -0.44865 0.25473 8399.00000 -1.761
## Conditionsem:Relatedrel -0.50207 0.25473 8399.00000 -1.971
## Conditionmorph:langL2 0.72538 0.25717 8399.00000 2.821
## Conditionorth:langL2 0.46795 0.25717 8399.00000 1.820
## Conditionsem:langL2 0.24502 0.25717 8399.00000 0.953
## Relatedrel:langL2 0.24896 0.25717 8399.00000 0.968
## langL2:hemisphereleft -0.28709 0.17707 8399.00000 -1.621
## langL2:hemisphereright 0.51494 0.17707 8399.00000 2.908
## Relatedrel:antposant -0.55117 0.16833 8399.00000 -3.274
## Relatedrel:antpospost 0.21767 0.16388 8399.00000 1.328
## langL2:antposant 0.07246 0.16861 8399.00000 0.430
## langL2:antpospost 0.85385 0.16411 8399.00000 5.203
## hemisphereleft:antposant -0.80776 0.24194 8399.00000 -3.339
## hemisphereright:antposant -0.17389 0.24194 8399.00000 -0.719
## hemisphereleft:antpospost -1.20863 0.21956 8399.00000 -5.505
## hemisphereright:antpospost -1.71544 0.21956 8399.00000 -7.813
## Conditionmorph:Relatedrel:langL2 -0.88344 0.36369 8399.00000 -2.429
## Conditionorth:Relatedrel:langL2 0.16889 0.36369 8399.00000 0.464
## Conditionsem:Relatedrel:langL2 -0.15017 0.36369 8399.00000 -0.413
## Pr(>|t|)
## (Intercept) 9.94e-06 ***
## Conditionmorph 0.213188
## Conditionorth 0.021085 *
## Conditionsem 0.080058 .
## Relatedrel 0.000332 ***
## langL2 0.004908 **
## hemisphereleft 0.885617
## hemisphereright 0.004846 **
## antposant 0.199016
## antpospost 0.007246 **
## Conditionmorph:Relatedrel 0.522021
## Conditionorth:Relatedrel 0.078232 .
## Conditionsem:Relatedrel 0.048760 *
## Conditionmorph:langL2 0.004804 **
## Conditionorth:langL2 0.068852 .
## Conditionsem:langL2 0.340734
## Relatedrel:langL2 0.333025
## langL2:hemisphereleft 0.104971
## langL2:hemisphereright 0.003645 **
## Relatedrel:antposant 0.001063 **
## Relatedrel:antpospost 0.184149
## langL2:antposant 0.667400
## langL2:antpospost 2.01e-07 ***
## hemisphereleft:antposant 0.000846 ***
## hemisphereright:antposant 0.472331
## hemisphereleft:antpospost 3.81e-08 ***
## hemisphereright:antpospost 6.22e-15 ***
## Conditionmorph:Relatedrel:langL2 0.015158 *
## Conditionorth:Relatedrel:langL2 0.642399
## Conditionsem:Relatedrel:langL2 0.679691
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t3.final.anova<-lmerTest::anova(t3.final)
t3.final.anova
## Analysis of Variance Table of type III with Satterthwaite
## approximation for degrees of freedom
## Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
## Condition 392.24 130.75 3 8399.0 14.926 1.092e-09 ***
## Related 447.67 447.67 1 8399.0 51.104 9.492e-13 ***
## lang 31.32 31.32 1 51.2 3.575 0.06431 .
## hemisphere 1852.85 926.42 2 8399.0 105.757 < 2.2e-16 ***
## antpos 1445.02 722.51 2 8399.0 82.479 < 2.2e-16 ***
## Condition:Related 90.75 30.25 3 8399.0 3.453 0.01578 *
## Condition:lang 85.55 28.52 3 8399.0 3.255 0.02071 *
## Related:lang 0.57 0.57 1 8399.0 0.065 0.79876
## lang:hemisphere 276.99 138.49 2 8399.0 15.810 1.402e-07 ***
## Related:antpos 241.84 120.92 2 8399.0 13.804 1.035e-06 ***
## lang:antpos 333.40 166.70 2 8399.0 19.030 5.676e-09 ***
## hemisphere:antpos 944.58 236.15 4 8399.0 26.957 < 2.2e-16 ***
## Condition:Related:lang 85.38 28.46 3 8399.0 3.249 0.02090 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Lmer-output of interest
Findings in 300-500
Both groups showed similar negativity attenuation in the later time-window at the posterior electrodes. The following model tests for language differences specifically at posterior sites for the 300-500 ms time-window
post300<-time300[time300$antpos=="post",]
post3.1<-lmer(mean~Condition*Related*lang*hemisphere+(1+Related|subj),post300)
#step(post3.1)
post3.final<-lmer(formula = mean ~ Condition + Related + lang + hemisphere +
(1 + Related | subj) + Condition:Related + lang:hemisphere,
data = post300)
summary(post3.final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
## to degrees of freedom [lmerMod]
## Formula: mean ~ Condition + Related + lang + hemisphere + (1 + Related |
## subj) + Condition:Related + lang:hemisphere
## Data: post300
##
## REML criterion at convergence: 16150.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4686 -0.6234 -0.0296 0.5768 7.8092
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## subj (Intercept) 5.856 2.420
## Relatedrel 1.059 1.029 0.10
## Residual 6.274 2.505
## Number of obs: 3392, groups: subj, 53
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 2.70715 0.49608 62.00000 5.457
## Conditionmorph 0.04361 0.17203 3276.00000 0.253
## Conditionorth -0.13262 0.17203 3276.00000 -0.771
## Conditionsem -0.17357 0.17203 3276.00000 -1.009
## Relatedrel 1.34311 0.22265 169.00000 6.032
## langL2 -0.79724 0.69204 56.00000 -1.152
## hemisphereleft -1.15316 0.15558 3276.00000 -7.412
## hemisphereright -1.25647 0.15558 3276.00000 -8.076
## Conditionmorph:Relatedrel -0.31132 0.24329 3276.00000 -1.280
## Conditionorth:Relatedrel -0.71152 0.24329 3276.00000 -2.925
## Conditionsem:Relatedrel -1.16094 0.24329 3276.00000 -4.772
## langL2:hemisphereleft -0.45774 0.22213 3276.00000 -2.061
## langL2:hemisphereright 0.70695 0.22213 3276.00000 3.183
## Pr(>|t|)
## (Intercept) 9.16e-07 ***
## Conditionmorph 0.79990
## Conditionorth 0.44082
## Conditionsem 0.31306
## Relatedrel 9.92e-09 ***
## langL2 0.25421
## hemisphereleft 1.58e-13 ***
## hemisphereright 8.88e-16 ***
## Conditionmorph:Relatedrel 0.20077
## Conditionorth:Relatedrel 0.00347 **
## Conditionsem:Relatedrel 1.90e-06 ***
## langL2:hemisphereleft 0.03941 *
## langL2:hemisphereright 0.00147 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtnm Cndtnr Cndtns Rltdrl langL2 hmsphrl hmsphrr
## Conditnmrph -0.173
## Conditinrth -0.173 0.500
## Conditionsm -0.173 0.500 0.500
## Relatedrel -0.090 0.386 0.386 0.386
## langL2 -0.684 0.000 0.000 0.000 0.000
## hemisphrlft -0.188 0.000 0.000 0.000 0.000 0.135
## hemsphrrght -0.188 0.000 0.000 0.000 0.000 0.135 0.600
## Cndtnmrph:R 0.123 -0.707 -0.354 -0.354 -0.546 0.000 0.000 0.000
## Cndtnrth:Rl 0.123 -0.354 -0.707 -0.354 -0.546 0.000 0.000 0.000
## Cndtnsm:Rlt 0.123 -0.354 -0.354 -0.707 -0.546 0.000 0.000 0.000
## lngL2:hmsphrl 0.132 0.000 0.000 0.000 0.000 -0.193 -0.700 -0.420
## lngL2:hmsphrr 0.132 0.000 0.000 0.000 0.000 -0.193 -0.420 -0.700
## Cndtnm:R Cndtnr:R Cndtns:R lngL2:hmsphrl
## Conditnmrph
## Conditinrth
## Conditionsm
## Relatedrel
## langL2
## hemisphrlft
## hemsphrrght
## Cndtnmrph:R
## Cndtnrth:Rl 0.500
## Cndtnsm:Rlt 0.500 0.500
## lngL2:hmsphrl 0.000 0.000 0.000
## lngL2:hmsphrr 0.000 0.000 0.000 0.600
lmerTest::anova(post3.final)
## Analysis of Variance Table of type III with Satterthwaite
## approximation for degrees of freedom
## Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
## Condition 306.13 102.04 3 3276.0 16.264 1.716e-10 ***
## Related 145.64 145.64 1 52.0 23.213 1.297e-05 ***
## lang 7.00 7.00 1 51.1 1.116 0.2957
## hemisphere 975.79 487.90 2 3276.0 77.765 < 2.2e-16 ***
## Condition:Related 160.85 53.62 3 3276.0 8.546 1.189e-05 ***
## lang:hemisphere 218.08 109.04 2 3276.0 17.380 3.104e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Posterior, 300-500, L1 and L2 together
lmer-output
Looking at the lmer results and the voltage maps, both groups show negativity attenuation in the posterior regions, but no attenuation in the orth condition.
The attenuation is strongest along the midline for the L1 group, but more broadly distributed across hemispheres in the L2 group.