set working directory load behavioral data
setwd("C:/Users/Katie/Desktop/Research/Dissertation/STUDIES/Studies 3 and 4 EEG/EEG Native French/Behavioral data")
bdata<-read.csv("For R native french eeg presentation data.csv",header=TRUE)
dim(bdata)
## [1] 119190 31
head(bdata)
## Subject Trial Event.Type Code Time TTime RT
## 1 KC02 1 Response 87 1843884 1834618 NA
## 2 KC02 2 Response 87 1960442 116471 11655.8
## 3 KC02 3 Picture fix_cross 1960531 0 8.9
## 4 KC02 3 Picture nothing 1970661 10130 1013.0
## 5 KC02 3 Picture forward_mask 1980791 20260 1013.0
## 6 KC02 3 Picture 99 1985856 25325 506.5
## Uncertainty Duration Uncertainty.1 ReqTime ReqDur Stim.Type Pair.Index
## 1 1 NA NA NA NA NA
## 2 1 NA NA NA NA NA
## 3 1 10130 2 0 10000 other 0
## 4 1 10130 2 10000 10000 other 0
## 5 1 5065 2 20000 5000 other 0
## 6 1 533 2 25000 500 other 0
## order List Lookup UseInRT TriggerType Condition Related Item
## 1 1 v1-1 KC02-1 #N/A response correct reject
## 2 2 v1-1 KC02-2 #N/A response correct reject
## 3 3 v1-1 KC02-3 #N/A
## 4 4 v1-1 KC02-3 #N/A
## 5 5 v1-1 KC02-3 #N/A
## 6 6 v1-1 KC02-3 #N/A
## First.or.Second respond.yes respond.no Word Accuracy
## 1 NA 1 0 0 0
## 2 NA 1 0 0 0
## 3 NA 0 0 0 1
## 4 NA 0 0 0 1
## 5 NA 0 0 0 1
## 6 NA 0 0 0 1
## Accuracy.for.target.trigger Cond.Above. Rel.Above Item.Above
## 1 0
## 2 1 correct reject 0
## 3 1 correct reject 0
## 4 1 0 0 0
## 5 1 0 0 0
## 6 1 0 0 0
Limit dataframe to just response lines
bdata<-bdata[bdata$TriggerType=="response",]
bdata$TriggerType<-factor(bdata$TriggerType)
bdata$Code<-factor(bdata$Code)
bdata<-bdata[bdata$Cond.Above.=="id"| bdata$Cond.Above.=="morph"| bdata$Cond.Above.=="orth"| bdata$Cond.Above.=="sem"| bdata$Cond.Above.=="nonce",]
head(bdata)
## Subject Trial Event.Type Code Time TTime RT Uncertainty
## 82 KC02 25 Response 88 2671792 2570 883.5 1
## 89 KC02 27 Response 77 2713631 1757 802.2 2
## 96 KC02 29 Response 88 2761070 6544 1280.8 2
## 103 KC02 31 Response 77 2802190 5012 1127.6 1
## 110 KC02 33 Response 77 2841950 2120 838.4 1
## 117 KC02 35 Response 77 2885069 2587 885.1 1
## Duration Uncertainty.1 ReqTime ReqDur Stim.Type Pair.Index order List
## 82 NA NA NA NA NA 82 v1-1
## 89 NA NA NA NA NA 89 v1-1
## 96 NA NA NA NA NA 96 v1-1
## 103 NA NA NA NA NA 103 v1-1
## 110 NA NA NA NA NA 110 v1-1
## 117 NA NA NA NA NA 117 v1-1
## Lookup UseInRT TriggerType Condition Related Item First.or.Second
## 82 KC02-25 yes response incorrect reject NA
## 89 KC02-27 yes response correct accept NA
## 96 KC02-29 yes response incorrect reject NA
## 103 KC02-31 yes response correct accept NA
## 110 KC02-33 yes response correct accept NA
## 117 KC02-35 yes response correct accept NA
## respond.yes respond.no Word Accuracy Accuracy.for.target.trigger
## 82 0 1 0 1 0
## 89 1 0 0 0 1
## 96 0 1 0 1 0
## 103 1 0 0 0 0
## 110 1 0 0 0 0
## 117 1 0 0 0 1
## Cond.Above. Rel.Above Item.Above
## 82 nonce unrel N044
## 89 sem unrel D073
## 96 nonce rel N017
## 103 orth unrel D055
## 110 orth rel D043
## 117 orth rel D069
dim(bdata)
## [1] 16519 31
limit dataframe to relevant columns
library(dplyr)
bdata<-bdata[,c(1,7,15,27,29:31)]
colnames(bdata)[5] <- "Condition"
colnames(bdata)[6] <- "Related"
colnames(bdata)[7] <- "Item"
bdata$Condition<-factor(bdata$Condition)
head(bdata)
## Subject RT order Accuracy Condition Related Item
## 82 KC02 883.5 82 1 nonce unrel N044
## 89 KC02 802.2 89 0 sem unrel D073
## 96 KC02 1280.8 96 1 nonce rel N017
## 103 KC02 1127.6 103 0 orth unrel D055
## 110 KC02 838.4 110 0 orth rel D043
## 117 KC02 885.1 117 0 orth rel D069
bdata<-bdata[bdata$Accuracy==1,]
Summarize RTs for each condition
library(plyr)
RT <- ddply(bdata, c("Condition", "Related"), summarize,
N = length(RT),
mean = round(mean(RT)),
sd = round(sd(RT),2),
se = round(sd / sqrt(N),2)
)
RT
## Condition Related N mean sd se
## 1 id rel 553 550 154.42 6.57
## 2 id unrel 466 575 151.77 7.03
## 3 morph rel 551 541 112.70 4.80
## 4 morph unrel 452 559 103.81 4.88
## 5 nonce rel 2634 778 223.17 4.35
## 6 nonce unrel 5249 778 215.25 2.97
## 7 orth rel 488 590 183.08 8.29
## 8 orth unrel 492 588 151.11 6.81
## 9 sem rel 479 559 124.00 5.67
## 10 sem unrel 478 561 109.04 4.99
Giving priming effect for each condition (related-unrelated)
id<-RT[1,4]-RT[2,4]
morph<-RT[3,4]-RT[4,4]
nonce<-RT[5,4]-RT[6,4]
orth<-RT[7,4]-RT[8,4]
sem<-RT[9,4]-RT[10,4]
effects<-rbind(id,morph,orth,sem,nonce)
effects
## [,1]
## id -25
## morph -18
## orth 2
## sem -2
## nonce 0
relevel to set unrelated as baseline
bdata$Related<-relevel(bdata$Related,ref="unrel")
plotting RTs
library(ggplot2)
ggplot(bdata, aes(x = Related, y = RT, fill = Related)) + geom_boxplot() +
facet_wrap(~Condition, ncol = 5)+ylim(500,1500)
load in properties .csv file
props<-read.csv("stim properties.csv",header=TRUE)
head(props)
## Item Condition Word Letters Frequency Syllables tar.rel.unrel
## 1 D001 Morph OSE 3 28.51 1 target
## 2 D002 Morph TUE 3 16.96 1 target
## 3 D003 Morph ARME 4 1.15 1 target
## 4 D004 Morph CITE 4 4.80 1 target
## 5 D005 Morph ERRE 4 2.64 1 target
## 6 D006 Morph JOUE 4 40.47 1 target
## rel.overlap word.nonce
## 1 NA word
## 2 NA word
## 3 NA word
## 4 NA word
## 5 NA word
## 6 NA word
targets<-props[props$tar.rel.unrel=="target" & props$word.nonce=="word",]
target_length<-targets[,c(1,4)]
target_freq<-targets[,c(1,5)]
target_syllables<-targets[,c(1,6)]
integrate lexical properties into bdata dataframe
library(qdap)
bdata$targetfreq<-lookup(bdata$Item,target_freq)
bdata$targetlength<-lookup(bdata$Item,target_length)
bdata$targetsyllables<-lookup(bdata$Item,target_syllables)
The below model includes all test conditions and nonce items to look at the effect of condition and prime relatedness on RTs
library(lme4)
library(lmerTest)
test1<-lmer(RT~Condition*Related+(1|Subject)+(1|Item),bdata)
summary(test1)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
## to degrees of freedom [lmerMod]
## Formula: RT ~ Condition * Related + (1 | Subject) + (1 | Item)
## Data: bdata
##
## REML criterion at convergence: 152747.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.0154 -0.5862 -0.1451 0.3559 6.3987
##
## Random effects:
## Groups Name Variance Std.Dev.
## Item (Intercept) 2687 51.84
## Subject (Intercept) 16210 127.32
## Residual 22271 149.23
## Number of obs: 11842, groups: Item, 288; Subject, 29
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 637.799 25.890 40.000 24.635 < 2e-16
## Conditionmorph -1.713 14.729 903.000 -0.116 0.907414
## Conditionnonce 140.517 11.394 752.000 12.333 < 2e-16
## Conditionorth 14.994 14.589 873.000 1.028 0.304357
## Conditionsem -6.490 14.550 922.000 -0.446 0.655653
## Relatedrel -31.463 9.444 11600.000 -3.332 0.000866
## Conditionmorph:Relatedrel 7.870 13.413 11597.000 0.587 0.557368
## Conditionnonce:Relatedrel 29.889 10.259 11708.000 2.913 0.003583
## Conditionorth:Relatedrel 30.214 13.471 11605.000 2.243 0.024921
## Conditionsem:Relatedrel 34.783 13.545 11602.000 2.568 0.010244
##
## (Intercept) ***
## Conditionmorph
## Conditionnonce ***
## Conditionorth
## Conditionsem
## Relatedrel ***
## Conditionmorph:Relatedrel
## Conditionnonce:Relatedrel **
## Conditionorth:Relatedrel *
## Conditionsem:Relatedrel *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtnm Cndtnn Cndtnr Cndtns Rltdrl Cndtnm:R Cndtnn:R
## Conditnmrph -0.283
## Conditinnnc -0.372 0.643
## Conditinrth -0.287 0.508 0.654
## Conditionsm -0.284 0.502 0.648 0.508
## Relatedrel -0.201 0.356 0.458 0.358 0.356
## Cndtnmrph:R 0.142 -0.508 -0.323 -0.251 -0.251 -0.704
## Cndtnnnc:Rl 0.185 -0.328 -0.467 -0.329 -0.328 -0.920 0.648
## Cndtnrth:Rl 0.142 -0.250 -0.322 -0.484 -0.251 -0.701 0.494 0.645
## Cndtnsm:Rlt 0.140 -0.245 -0.318 -0.248 -0.488 -0.697 0.490 0.641
## Cndtnr:R
## Conditnmrph
## Conditinnnc
## Conditinrth
## Conditionsm
## Relatedrel
## Cndtnmrph:R
## Cndtnnnc:Rl
## Cndtnrth:Rl
## Cndtnsm:Rlt 0.488
Temporarily remove participant KC06 from analysis. This is because there was a problem mapping the responses to specific target items, causing trouble with lexical properties. Once I am able to fix the item mapping, I’ll add her back into analyses
bdata<-bdata[bdata$Subject!="KC06",]
Remove nonce items from dataframe to allow checking for the effects of target lexical properties
bdata<-bdata[bdata$Condition!="nonce",]
test1<-lmer(RT~Condition*Related+(1|Subject)+(1|Item),bdata)
test2<-lmer(RT~Condition*Related+targetfreq+(1|Subject)+(1|Item),bdata)
summary(test2)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
## to degrees of freedom [lmerMod]
## Formula: RT ~ Condition * Related + targetfreq + (1 | Subject) + (1 |
## Item)
## Data: bdata
##
## REML criterion at convergence: 46872.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.0403 -0.4449 -0.0788 0.3269 9.3883
##
## Random effects:
## Groups Name Variance Std.Dev.
## Item (Intercept) 4279 65.41
## Subject (Intercept) 6668 81.66
## Residual 9508 97.51
## Number of obs: 3871, groups: Item, 144; Subject, 28
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 632.4129 19.7892 64.0000 31.958 < 2e-16
## Conditionmorph -18.2270 16.7746 163.0000 -1.087 0.278822
## Conditionorth 6.3458 16.7344 162.0000 0.379 0.705034
## Conditionsem -10.7747 16.7926 162.0000 -0.642 0.522016
## Relatedrel -35.7290 6.2453 3708.0000 -5.721 1.14e-08
## targetfreq -0.5396 0.1370 135.0000 -3.939 0.000131
## Conditionmorph:Relatedrel 14.7032 8.8868 3708.0000 1.654 0.098111
## Conditionorth:Relatedrel 34.7918 8.9213 3709.0000 3.900 9.79e-05
## Conditionsem:Relatedrel 33.5692 8.9609 3709.0000 3.746 0.000182
##
## (Intercept) ***
## Conditionmorph
## Conditionorth
## Conditionsem
## Relatedrel ***
## targetfreq ***
## Conditionmorph:Relatedrel .
## Conditionorth:Relatedrel ***
## Conditionsem:Relatedrel ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtnm Cndtnr Cndtns Rltdrl trgtfr Cndtnm:R Cndtnr:R
## Conditnmrph -0.425
## Conditinrth -0.419 0.499
## Conditionsm -0.409 0.497 0.502
## Relatedrel -0.173 0.202 0.203 0.202
## targetfreq -0.167 0.013 -0.030 -0.079 0.003
## Cndtnmrph:R 0.121 -0.290 -0.143 -0.142 -0.703 -0.001
## Cndtnrth:Rl 0.120 -0.141 -0.277 -0.141 -0.700 -0.001 0.492
## Cndtnsm:Rlt 0.121 -0.141 -0.142 -0.279 -0.697 0.002 0.489 0.487