Visualizing higher-order polynomial terms

Dan Mirman

24 January 2019

A problem with polynomials

It can be hard to interpret effects on the higher-order terms.

Example: function vs. thematic competition in VWP

ggplot(subset(FunctTheme, Object!="Target"), aes(Time, meanFix, color=Object, fill=Object)) + 
  facet_wrap(~ Condition) + stat_summary(fun.y=mean, geom="line") + 
  stat_summary(fun.data=mean_se, geom="ribbon", color=NA, alpha=0.3) + 
  theme_bw() + labs(x="Time Since Word Onset (ms)", y="Fixation Proportion") +
  legend_positioning(c(1,1))

Function-Thematic GCA

FT.gca <- code_poly(subset(FunctTheme, Object!="Target"), predictor = "Time", poly.order = 4)

m.ft <- lmer(meanFix ~ (poly1+poly2+poly3+poly4)*Object*Condition + 
               (1+poly1+poly2+poly3+poly4 | Subject) +
               (1+poly1+poly2+poly3+poly4 | Subject:Object:Condition),
             data=FT.gca, REML=F)

Function-Thematic GCA: check model fit

FT.gca$GCA_Full <- fitted(m.ft) # add fitted data to original data frame
ggplot(FT.gca, aes(Time, meanFix, color=Object)) + facet_wrap(~ Condition) + 
  stat_summary(fun.data=mean_se, geom="pointrange") + 
  stat_summary(aes(y=GCA_Full), fun.y=mean, geom="line") + 
  theme_bw() + labs(x="Time Since Word Onset (ms)", y="Fixation Proportion") +
  legend_positioning(c(1,1))

Function-Thematic GCA: p-values

get_pvalues(m.ft)[16:20, ]
##                                          Estimate Std..Error t.value
## ObjectUnrelated:ConditionThematic       -0.004164    0.01709 -0.2436
## poly1:ObjectUnrelated:ConditionThematic  0.065878    0.07745  0.8506
## poly2:ObjectUnrelated:ConditionThematic -0.047568    0.04362 -1.0906
## poly3:ObjectUnrelated:ConditionThematic -0.156184    0.05181 -3.0145
## poly4:ObjectUnrelated:ConditionThematic  0.075709    0.03308  2.2888
##                                         p.normal p.normal.star
## ObjectUnrelated:ConditionThematic       0.807512              
## poly1:ObjectUnrelated:ConditionThematic 0.394969              
## poly2:ObjectUnrelated:ConditionThematic 0.275452              
## poly3:ObjectUnrelated:ConditionThematic 0.002574            **
## poly4:ObjectUnrelated:ConditionThematic 0.022090             *

What do those significant effects on the 3rd- and 4th-order polynomial terms mean? Do they correspond to the early-vs-later competition time course difference?

Function-Thematic GCA: fit reduced model

m.reduced <- lmer(meanFix ~ (poly1+poly2+poly3+poly4)*Object + # full Object effects
                    (poly1+poly2+poly3+poly4)*Condition + # full Condition effects
                    (poly1+poly2)*Object*Condition + # reduced Obj-by-Cond interactions
                    (1+poly1+poly2+poly3+poly4 | Subject) +
                    (1+poly1+poly2 | Subject:Object:Condition), # reduced random effect
              data=FT.gca, REML=F)
## singular fit

Note that both the fixed effects and random effects for the interaction are removed from this reduced model.

For the statistical model comparison, we only reduce the fixed effects to evaluate group-level differences. This is for a visual (qualitative) comparison – to see what happens when higher-order interaction terms are the same for all conditions.

Function-Thematic GCA: visually compare model fits

FT.gca$GCA_Reduced <- fitted(m.reduced) # add fitted data to original data frame
ggplot(FT.gca, aes(Time, meanFix, color=Object)) + facet_wrap(~ Condition) + 
  stat_summary(fun.data=mean_se, geom="pointrange") + 
  stat_summary(aes(y=GCA_Full), fun.y=mean, geom="line") + 
  stat_summary(aes(y=GCA_Reduced), fun.y=mean, geom="line", linetype="dashed") + 
  theme_bw() + labs(x="Time Since Word Onset (ms)", y="Fixation Proportion") +
  legend_positioning(c(1,1))

Ok, sort of looks like maybe the Function competition effect is earlier in reduced model and Thematic competition effect is later (i.e., smaller competition time course difference), but hard to tell.

Function-Thematic GCA: competition effect sizes

It might be easier if we compute competition effect sizes (Comp - Unrel), so we’ll have half as much to plot.

#library(plyr)
ES <- FT.gca %>% group_by(Subject, Time, Condition) %>%
  summarize(Competition = meanFix[Object=="Competitor"] - meanFix[Object=="Unrelated"], 
            GCA_Full = GCA_Full[Object=="Competitor"] - GCA_Full[Object=="Unrelated"], 
            GCA_Reduced = GCA_Reduced[Object=="Competitor"] - GCA_Reduced[Object=="Unrelated"])
summary(ES)
##     Subject         Time         Condition    Competition     
##  21     : 34   Min.   : 500   Function:255   Min.   :-0.2812  
##  24     : 34   1st Qu.: 700   Thematic:255   1st Qu.:-0.0625  
##  25     : 34   Median : 900                  Median : 0.0000  
##  27     : 34   Mean   : 900                  Mean   : 0.0215  
##  28     : 34   3rd Qu.:1100                  3rd Qu.: 0.0702  
##  40     : 34   Max.   :1300                  Max.   : 0.4000  
##  (Other):306                                                  
##     GCA_Full        GCA_Reduced     
##  Min.   :-0.2394   Min.   :-0.3123  
##  1st Qu.:-0.0375   1st Qu.:-0.0231  
##  Median : 0.0143   Median : 0.0209  
##  Mean   : 0.0215   Mean   : 0.0214  
##  3rd Qu.: 0.0759   3rd Qu.: 0.0630  
##  Max.   : 0.3320   Max.   : 0.2610  
## 

Function-Thematic GCA: plot competition effect sizes

ggplot(ES, aes(Time, Competition, color=Condition)) + 
  stat_summary(fun.y=mean, geom="point") + 
  stat_summary(aes(y=GCA_Full), fun.y=mean, geom="line") + 
  stat_summary(aes(y=GCA_Reduced), fun.y=mean, geom="line", linetype="dashed") + 
  theme_bw() + labs(x="Time Since Word Onset (ms)", y="Competition") + 
  legend_positioning(c(1,1))

Now can see that solid lines pull apart the time course, but the dashed lines are almost the same. That is, the full model (with poly3:Object:Condition and poly4:Object:Condition) captured the time course difference, but the reduced model did not.

Break: 2:30 - 3:15pm