Dan Mirman
28 November 2019
Time | Topic | Data set(s) |
---|---|---|
10-10:30 | Introduction | Visual Search |
10:30-11 | Exercise | WISQARS, Naming Recovery |
11-11:45 | Non-linear change | Word Learning |
Lunch | Exercise | CP |
13-13:45 | Within-subject effects | Target Fixation |
13:45-14:30 | Exercise | Az |
14:30-15:15 | Contrast coding, Multiple comparisons | Motor Learning, Naming Recovery |
15:15-16 | Exercise | WISQARS |
Time | Topic | Data set(s) |
---|---|---|
12-12:30 | Logistic GCA | Target Fixation |
12:30-13 | Exercise | Word Learning |
13-14 | Individual Differences | Deviant Behavior, School Mental Health |
14-17 | Hands-on analysis time | Own data |
Nested data are not independent
Nested data are not independent
Related by continuous variable (i.e., time, but could be [letter] size, number of distractors, etc.)
Level 1: \(Y_{ij} = \beta_{0i} + \beta_{1i} \cdot Time_{j} + \epsilon_{ij}\)
Level 2: model of the Level 1 parameter(s)
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 effects
Random effects
# the psy811 package includes helper functions and example data sets
# to install: devtools::install_github("dmirman/psy811")
library(psy811)
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
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.1566
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Df | A | IC B | IC lo | gLik de | viance C | hisq Ch | i Df Pr | (>Chisq) |
---|---|---|---|---|---|---|---|---|
vs.null | 5 | 2283 | 2297 | -1136 | 2273 | NA | NA | NA |
vs | 6 | 2248 | 2265 | -1118 | 2236 | 36.903 | 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.1566 |
vs
) substantially improves model fit: response times are affected by number of distractorsvs.0
) significantly improves model fit: stroke survivors respond more slowly than controls dovs.1
), does not significantly improve model fit: stroke survivors are not more affected by distractors than controls are## 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) 613397 783.2
## Set.Size 380 19.5 1.00
## Residual 756827 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
## convergence code: 0
## boundary (singular) fit: see ?isSingular
## 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.956e-11 ***
## DxControl -1106.05 357.95 -3.090 2.002e-03 **
## Set.Size:DxControl -21.74 15.20 -1.430 1.528e-01
## 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
Exercise 1A: Analyze the US state-level suicide rate data from the WISQARS (wisqars.suicide
)
Exercise 1B: Analyze the recovery of object naming ability in aphasia (NamingRecovery
)