Eye-Tracking Analysis Tutorial

Dan Mirman

24 January 2019

Workshop Schedule

Day 1: Data wrangling, Pre-processing eye-tracking data

Day 2: Statistical analysis of eye-tracking data (GCA)
Time Content
9am - 10am GCA basics
10am - 11:15am Modeling non-linear change
11:15 - Noon Within-subjects effects
Noon - 1:00pm Lunch break, Q&A, own data analysis time
1:00pm - 1:45pm Logistic GCA
1:45pm - 2:30pm Visualizing higher-order polynomial terms
2:30pm - 3:15pm Break, own data analysis time
3:15pm - 4:15pm Quantifying and analyzing individual differences
4:15pm - 5pm Own data analysis time

What are time course data?

Two key features

Nested data are not independent

Two key features

Nested data are not independent

Related by continuous variable (i.e., time, but could be [letter] size, number of distractors, etc.)

Gradual change

Replication crisis

Linear regression: A brief review

Multilevel regression: Fixed effects

Level 1: \(Y_{ij} = \beta_{0i} + \beta_{1i} \cdot Time_{j} + \epsilon_{ij}\)

Level 2: model of the Level 1 parameter(s)

Multilevel regression: Random effects

Level 1: \(Y_{ij} = \beta_{0i} + \beta_{1i} \cdot Time_{j} + \epsilon_{ij}\)

Level 2:

\(\beta_{0i} = \gamma_{00} + \gamma_{0C} \cdot C + \zeta_{0i}\)

\(\beta_{1i} = \gamma_{10} + \gamma_{1C} \cdot C + \zeta_{1i}\)

Residual errors

Fixed vs. Random effects

Fixed effects

Random effects

Maximum Likelihood Estimation

A simple (linear) GCA example

library(gazer)
load("VisualSearchEx.rda") # not in gazer package
summary(VisualSearchEx)
##   Participant        Dx        Set.Size          RT       
##  0042   :  4   Aphasic:60   Min.   : 1.0   Min.   :  414  
##  0044   :  4   Control:72   1st Qu.: 4.0   1st Qu.: 1132  
##  0083   :  4                Median :10.0   Median : 1814  
##  0166   :  4                Mean   :12.8   Mean   : 2261  
##  0186   :  4                3rd Qu.:18.8   3rd Qu.: 2808  
##  0190   :  4                Max.   :30.0   Max.   :12201  
##  (Other):108
ggplot(VisualSearchEx, aes(Set.Size, RT, color=Dx)) + 
  stat_summary(fun.data=mean_se, geom="pointrange")

A simple (linear) GCA example: Fit the models

library(lme4)
# a null, intercept-only model
vs.null <- lmer(RT ~ 1 + (Set.Size | Participant), data=VisualSearchEx, REML=FALSE)
# add effect of set size
vs <- lmer(RT ~ Set.Size + (Set.Size | Participant), data=VisualSearchEx, REML=F)
# add effect of diagnosis
vs.0 <- lmer(RT ~ Set.Size + Dx + (Set.Size | Participant), data=VisualSearchEx, REML=F)
# add set size by diagnosis interaction
vs.1 <- lmer(RT ~ Set.Size * Dx + (Set.Size | Participant), data=VisualSearchEx, REML=F)
# compare model fits
anova(vs.null, vs, vs.0, vs.1)
## Data: VisualSearchEx
## Models:
## vs.null: RT ~ 1 + (Set.Size | Participant)
## vs: RT ~ Set.Size + (Set.Size | Participant)
## vs.0: RT ~ Set.Size + Dx + (Set.Size | Participant)
## vs.1: RT ~ Set.Size * Dx + (Set.Size | Participant)
##         Df  AIC  BIC logLik deviance Chisq Chi Df Pr(>Chisq)    
## vs.null  5 2283 2297  -1136     2273                            
## vs       6 2248 2265  -1118     2236 36.90      1    1.2e-09 ***
## vs.0     7 2241 2261  -1114     2227  8.58      1     0.0034 ** 
## vs.1     8 2241 2264  -1113     2225  2.01      1     0.1567    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

A simple (linear) GCA example: Interpet results

Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
vs.null 5 2283 2297 -1136 2273 NA NA NA
vs 6 2248 2265 -1118 2236 36.902 1 0.0000
vs.0 7 2241 2261 -1114 2227 8.585 1 0.0034
vs.1 8 2241 2264 -1113 2225 2.006 1 0.1567

A simple (linear) GCA example: Inspect model

summary(vs.1)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: RT ~ Set.Size * Dx + (Set.Size | Participant)
##    Data: VisualSearchEx
## 
##      AIC      BIC   logLik deviance df.resid 
##     2241     2264    -1113     2225      124 
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -3.759 -0.317 -0.079  0.317  6.229 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev. Corr
##  Participant (Intercept) 613393   783.2        
##              Set.Size       380    19.5    1.00
##  Residual                756830   870.0        
## Number of obs: 132, groups:  Participant, 33
## 
## Fixed effects:
##                    Estimate Std. Error t value
## (Intercept)          2078.7      264.4    7.86
## Set.Size               73.5       11.2    6.54
## DxControl           -1106.1      357.9   -3.09
## Set.Size:DxControl    -21.7       15.2   -1.43
## 
## Correlation of Fixed Effects:
##             (Intr) Set.Sz DxCntr
## Set.Size    -0.090              
## DxControl   -0.739  0.066       
## St.Sz:DxCnt  0.066 -0.739 -0.090

A simple (linear) GCA example: Parameter p-values

get_pvalues(vs.1) #default: normal approximation
##                    Estimate Std..Error t.value  p.normal p.normal.star
## (Intercept)         2078.75     264.36   7.863 3.775e-15           ***
## Set.Size              73.49      11.23   6.545 5.955e-11           ***
## DxControl          -1106.05     357.95  -3.090 2.002e-03            **
## Set.Size:DxControl   -21.74      15.20  -1.430 1.528e-01
get_pvalues(vs.1, method = "KR") # alternative: Kenward-Roger approximation for DF
##                    Estimate Std..Error t.value df.KR      p.KR p.KR.star
## (Intercept)         2078.75     264.36   7.863    31 7.103e-09       ***
## Set.Size              73.49      11.23   6.545    31 2.630e-07       ***
## DxControl          -1106.05     357.95  -3.090    31 4.204e-03        **
## Set.Size:DxControl   -21.74      15.20  -1.430    31 1.628e-01

A simple (linear) GCA example: Plot model fit

ggplot(VisualSearchEx, aes(Set.Size, RT, color=Dx)) + 
  stat_summary(fun.data=mean_se, geom="pointrange") + 
  stat_summary(aes(y=fitted(vs.0)), fun.y=mean, geom="line")

A simple (linear) GCA example: Compare model fits

ggplot(VisualSearchEx, aes(Set.Size, RT, color=Dx)) + 
  stat_summary(fun.data=mean_se, geom="pointrange") + 
  stat_summary(aes(y=fitted(vs.0)), fun.y=mean, geom="line") +
  stat_summary(aes(y=fitted(vs.1)), fun.y=mean, geom="line", linetype="dashed")

Exercise

Analyze the recovery of object naming ability in aphasia (NamingRecovery)

ggplot(NamingRecovery, aes(TestTime, Correct, color=Diagnosis)) + 
  stat_summary(fun.data=mean_se, geom="pointrange",
               position=position_dodge(width=0.1))

Exercise Solution

Analyze the recovery of object naming ability in aphasia (NamingRecovery)

nr.null <- lmer(Correct ~ 1 + (TestTime | SubjectID), data = NamingRecovery, REML=F)
nr.base <- lmer(Correct ~ TestTime + (TestTime | SubjectID), data = NamingRecovery, REML=F)
nr.0 <- lmer(Correct ~ TestTime + Diagnosis + (TestTime | SubjectID), data = NamingRecovery, REML=F)
nr.1 <- lmer(Correct ~ TestTime * Diagnosis + (TestTime | SubjectID), data = NamingRecovery, REML=F)
anova(nr.null, nr.base, nr.0, nr.1) 
## Data: NamingRecovery
## Models:
## nr.null: Correct ~ 1 + (TestTime | SubjectID)
## nr.base: Correct ~ TestTime + (TestTime | SubjectID)
## nr.0: Correct ~ TestTime + Diagnosis + (TestTime | SubjectID)
## nr.1: Correct ~ TestTime * Diagnosis + (TestTime | SubjectID)
##         Df  AIC  BIC logLik deviance Chisq Chi Df Pr(>Chisq)    
## nr.null  5 -126 -112   67.8     -136                            
## nr.base  6 -146 -130   79.2     -158 22.84      1    1.8e-06 ***
## nr.0     8 -151 -129   83.6     -167  8.72      2      0.013 *  
## nr.1    10 -147 -120   83.7     -167  0.26      2      0.880    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
get_pvalues(nr.1)
##                               Estimate Std..Error t.value  p.normal
## (Intercept)                   0.733127    0.10395  7.0525 1.757e-12
## TestTime                      0.054005    0.01562  3.4584 5.433e-04
## DiagnosisConduction          -0.167822    0.13420 -1.2505 2.111e-01
## DiagnosisWernicke            -0.393292    0.13752 -2.8600 4.237e-03
## TestTime:DiagnosisConduction -0.001558    0.02016 -0.0773 9.384e-01
## TestTime:DiagnosisWernicke   -0.009332    0.02066 -0.4518 6.514e-01
##                              p.normal.star
## (Intercept)                            ***
## TestTime                               ***
## DiagnosisConduction                       
## DiagnosisWernicke                       **
## TestTime:DiagnosisConduction              
## TestTime:DiagnosisWernicke