Chapter 5 Mixed Models
5.1 Linear Mixed Models
The example is based on data from an Experiment performed by Freeman, Heathcote, Chalmers, and Hockley (2010). In the example a simplified analysis of the data is performed, using only Task and Stimulus as fixed factors and stimulus by subject as random effect.
5.1.1 Results Overview
JASP | SPSS | SAS | Minitab | R | |
---|---|---|---|---|---|
F(Task) | 15.0731 | 15.075 | 15.07 | 15.08 | 15.07 |
F(Stimulus) | 88.7032 | 88.716 | 88.70 | 88.72 | 88.70 |
F(Task X Stimulus) | 37.8429 | 37.846 | 37.84 | 37.85 | 37.84 |
5.1.3 SPSS
DATASET ACTIVATE DataSet1.
MIXED rt BY task stimulus WITH NumID/CRITERIA=DFMETHOD(SATTERTHWAITE) CIN(95) MXITER(100) MXSTEP(10) SCORING(1)
SINGULAR(0.000000000001) HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE)
/FIXED=task stimulus task*stimulus | NOINT SSTYPE(3)
/METHOD=REML
/RANDOM=INTERCEPT stimulus | SUBJECT(NumID) COVTYPE(VC).
5.1.4 SAS
proc mixed;
class Task Stimulus;= Task Stimulus Task*Stimulus / ddfm=satterth;
model rt / type=un subject=NumID g;
random intercept Stimulus run;
5.1.6 R
#install.packages("afex")
library("afex")
## Loading required package: lme4
## Loading required package: Matrix
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: emmeans() for ANOVA models now uses model = 'multivariate' as default.
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
##
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
##
## lmer
set_sum_contrasts() ## not strictly necessary
## setting contr.sum globally: options(contrasts=c('contr.sum', 'contr.poly'))
### but always a good idea
<- mixed(rt ~ task*stimulus +
m1 |id), data = LMM.data, method="S")
(stimulus m1
## Mixed Model Anova Table (Type 3 tests, S-method)
##
## Model: rt ~ task * stimulus + (stimulus | id)
## Data: LMM.data
## Effect df F p.value
## 1 task 1, 42.98 15.07 *** <.001
## 2 stimulus 1, 42.89 88.70 *** <.001
## 3 task:stimulus 1, 42.89 37.84 *** <.001
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1