Growth Curve Analysis, Part 3

Dan Mirman

22 May 2020

Random effects

Within-subject effects

Example: Target fixation in spoken word-to-picure matching (VWP)

ggplot(TargetFix, aes(Time, meanFix, color=Condition, fill=Condition)) +
  stat_summary(fun=mean, geom="line") +
  stat_summary(fun.data=mean_se, geom="ribbon", color=NA, alpha=0.3) +
  theme_bw() + expand_limits(y=c(0,1)) + legend_positioning(c(1,1)) +
  labs(y="Fixation Proportion", x="Time since word onset (ms)")

Within-subject effects: prep for GCA

TargetFix.gca <- code_poly(TargetFix, predictor="Time", poly.order=3)

str(TargetFix.gca)
## 'data.frame':    300 obs. of  11 variables:
##  $ Subject   : Factor w/ 10 levels "708","712","715",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Time      : num  300 300 350 350 400 400 450 450 500 500 ...
##  $ timeBin   : num  1 1 2 2 3 3 4 4 5 5 ...
##  $ Condition : Factor w/ 2 levels "High","Low": 1 2 1 2 1 2 1 2 1 2 ...
##  $ meanFix   : num  0.1944 0.0286 0.25 0.1143 0.2778 ...
##  $ sumFix    : num  7 1 9 4 10 5 13 5 14 6 ...
##  $ N         : int  36 35 36 35 36 35 36 35 36 35 ...
##  $ Time.Index: num  1 1 2 2 3 3 4 4 5 5 ...
##  $ poly1     : num  -0.418 -0.418 -0.359 -0.359 -0.299 ...
##  $ poly2     : num  0.4723 0.4723 0.2699 0.2699 0.0986 ...
##  $ poly3     : num  -0.4563 -0.4563 -0.0652 -0.0652 0.1755 ...

Within-subject effects: fit full GCA model

m.full <- lmer(meanFix ~ (poly1+poly2+poly3)*Condition + #fixed effects
                 (poly1+poly2+poly3 | Subject) + #random effects of Subject
                 (poly1+poly2+poly3 | Subject:Condition), #random effects of Subj by Cond
               data=TargetFix.gca, REML=F)
## boundary (singular) fit: see ?isSingular
get_pvalues(m.full)
##                      Estimate Std..Error    df   t.value  Pr...t..  p.normal
## (Intercept)         0.4773228    0.01385 19.87 34.457856 3.383e-19 0.000e+00
## poly1               0.6385604    0.05994 17.27 10.654065 5.152e-09 0.000e+00
## poly2              -0.1095979    0.03849 19.99 -2.847535 9.954e-03 4.406e-03
## poly3              -0.0932612    0.02330 18.07 -4.001954 8.305e-04 6.282e-05
## ConditionLow       -0.0581122    0.01879 16.22 -3.093146 6.891e-03 1.980e-03
## poly1:ConditionLow  0.0003188    0.06579 15.70  0.004846 9.962e-01 9.961e-01
## poly2:ConditionLow  0.1635455    0.05393 19.08  3.032574 6.826e-03 2.425e-03
## poly3:ConditionLow -0.0020869    0.02705 16.67 -0.077163 9.394e-01 9.385e-01
##                    p.normal.star
## (Intercept)                  ***
## poly1                        ***
## poly2                         **
## poly3                        ***
## ConditionLow                  **
## poly1:ConditionLow              
## poly2:ConditionLow            **
## poly3:ConditionLow

Within-subject effects: random effects

##     (Intercept)    poly1      poly2     poly3
## 708  -0.0001522  0.01085 -0.0035635 -0.004929
## 712   0.0110222  0.10693 -0.0093253 -0.036517
## 715   0.0113775  0.11482 -0.0109566 -0.039652
## 720  -0.0020717 -0.01300 -0.0003714  0.003738
## 722   0.0138362  0.16223 -0.0200919 -0.058180
## 725  -0.0178395 -0.20733  0.0253549  0.074204

Within-subject effects: random effects

# str(ranef(m.full))
VarCorr(m.full)
##  Groups            Name        Std.Dev. Corr             
##  Subject:Condition (Intercept) 0.0405                    
##                    poly1       0.1404   -0.43            
##                    poly2       0.1124   -0.33  0.72      
##                    poly3       0.0417    0.13 -0.49 -0.43
##  Subject           (Intercept) 0.0124                    
##                    poly1       0.1195    0.91            
##                    poly2       0.0165   -0.42 -0.76      
##                    poly3       0.0421   -0.85 -0.99  0.83
##  Residual                      0.0438

What is being estimated?

This is why df for parameter estimates are poorly defined in MLR

Alternative random effects structure

m.left <- lmer(meanFix ~ (poly1+poly2+poly3)*Condition + #fixed effects
                ((poly1+poly2+poly3)*Condition | Subject), #random effects
              data=TargetFix.gca, REML=F)
## boundary (singular) fit: see ?isSingular
get_pvalues(m.left)
##                      Estimate Std..Error     df   t.value  Pr...t..  p.normal
## (Intercept)         0.4773228    0.01679 10.003 28.436524 6.691e-11 0.000e+00
## poly1               0.6385604    0.05146 10.000 12.407713 2.133e-07 0.000e+00
## poly2              -0.1095979    0.03717 10.004 -2.948277 1.457e-02 3.196e-03
## poly3              -0.0932612    0.02063 10.039 -4.521487 1.095e-03 6.141e-06
## ConditionLow       -0.0581122    0.02110 10.005 -2.754110 2.033e-02 5.885e-03
## poly1:ConditionLow  0.0003188    0.07479  9.994  0.004263 9.967e-01 9.966e-01
## poly2:ConditionLow  0.1635455    0.06274 10.000  2.606797 2.618e-02 9.139e-03
## poly3:ConditionLow -0.0020869    0.03334 10.676 -0.062602 9.512e-01 9.501e-01
##                    p.normal.star
## (Intercept)                  ***
## poly1                        ***
## poly2                         **
## poly3                        ***
## ConditionLow                  **
## poly1:ConditionLow              
## poly2:ConditionLow            **
## poly3:ConditionLow

Alternative random effects structure

# str(ranef(m.left))
# head(ranef(m.left)$"Subject")
VarCorr(m.left)
##  Groups   Name               Std.Dev. Corr                                     
##  Subject  (Intercept)        0.0519                                            
##           poly1              0.1570    0.18                                    
##           poly2              0.1094   -0.29  0.03                              
##           poly3              0.0491   -0.28 -0.37  0.63                        
##           ConditionLow       0.0649   -0.89 -0.13  0.49  0.34                  
##           poly1:ConditionLow 0.2286    0.38 -0.46 -0.62  0.10 -0.56            
##           poly2:ConditionLow 0.1889    0.20  0.08 -0.81 -0.22 -0.43  0.74      
##           poly3:ConditionLow 0.0862   -0.08 -0.40 -0.06 -0.47  0.06 -0.27 -0.43
##  Residual                    0.0430

This random effect structure makes fewer assumptions:

Alternative random effects structure requires more parameters

Convergence problems

Warning message: 
In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf, : 
    failure to converge in 10000 evaluations

Need to simplify random effects

Outcome ~ (poly1+poly2+poly3)*Condition + (poly1+poly2+poly3 | Subject)
Outcome ~ (poly1+poly2+poly3)*Condition + (poly1+poly2 | Subject)
Outcome ~ (poly1+poly2+poly3)*Condition + (1 | Subject) + 
  (0+poly1 | Subject) + (0+poly2 | Subject) + (0+poly3 | Subject)

Participants as fixed vs. random effects

In general, participants should be treated as random effects.

This captures the typical assumption of random sampling from some population to which we wish to generalize.

Pooling

http://tjmahr.github.io/plotting-partial-pooling-in-mixed-effects-models/

http://tjmahr.github.io/plotting-partial-pooling-in-mixed-effects-models/

Participants as fixed vs. random effects

In general, participants should be treated as random effects.

This captures the typical assumption of random sampling from some population to which we wish to generalize.

Shrinkage

http://tjmahr.github.io/plotting-partial-pooling-in-mixed-effects-models/

http://tjmahr.github.io/plotting-partial-pooling-in-mixed-effects-models/

Participants as fixed vs. random effects

In general, participants should be treated as random effects.

This captures the typical assumption of random sampling from some population to which we wish to generalize.

Exceptions are possible: e.g., neurological/neuropsychological case studies where the goal is to characterize the pattern of performance for each participant, not generalize to a population.

Lunch break; Exercise 3

Az: Use natural (not orthogonal) polynomials to analyze decline in performance of 30 individuals with probable Alzheimer’s disease on three different kinds of tasks - Memory, complex ADL, and simple ADL.