[R-sig-ME] Looking for help in moving from a full factorial repeated measure anova to a LME model
ph||||p@@|d@y @end|ng |rom mp|@n|
Sat Sep 28 23:26:54 CEST 2019
sorry for not getting back to you sooner, especially when you actually
had a minimum working example ....
I suspect part of the problem is that anova() in R corresponds to a Type
I ANOVA, while the default in SPSS (if I recall correctly) is Type III.
I personally think Type III isn't terribly sensical and think Type II is
the way to go, but that's another topic. There's a lot of commentary and
explanations on these things. John Fox has posted various things on this
list to that effect, while Bill Venables has an excellent commentary on
the issue ("Exegeses on Linear Models":
In practical terms, you need to load the car package and then try
The other thing that could be creating discrepancies is that you only
have a by-subjects intercept and no by-subjects slope. The choice of
random effects structure is a relatively big topic, and there are lots
of different things to read depending on your level of math. There's the
often cited 'Keep it maximal' paper by Barr et al. (2013, J Mem & Lang),
but I have some objections to that. Instead, I would recommend
'Balancing Type I error and power' by Matuschek et al. (2017, JML), or
the arXiv paper 'Parsimonous Mixed Models' (Bates et al.) or the
nextjournal paper 'Complexity in fitting Linear Mixed Models (Bates,
Hope that helps, even a year and a half later ....
On 31/05/2018 13:37, Blazej Mrozinski wrote:
> Greetings to all group members,
> I'm having troubles in setting up a linear mixed model for analyzing a
> balanced factorial within-subject design
> I would normally use GLM Repeated Measures in SPSS on aggregated data-
> which is what I already did with current and previous data, but want to
> avoid losing participants due to missing data listwise deletion associated
> with GLM module.
> Otherwise, I'd like everything as in GLM Repeated Measures - that is: all
> main effects and all interactions.
> I understand that to use LME I need to have a raw datafile with separate
> line for each observation (multiple lines per participant). [Preparing such
> data file is not a problem].
> I am, however, unsure about proper syntax to get an equivalent of GLM
> Repeated Measures while using LME4.
> This is some exemplary R code that mimics my real data structure (in raw /
> long format):
> library(AlgDesign) #for generating a factorial design)
> df <-gen.factorial(c(8,2,2,2,2,10), factors = "all",
> varNames = c("rep", "A", "B", "C", "D", "Subject"))
> df$rep <- as.numeric(df$rep)
> df$Subject <- as.numeric(df$Subject)
> response <- sample(0:1, 1280, replace=TRUE, prob = c(0.3, 0.7))
> logRT <- rnorm(n=1280, m=7, sd=1)
> df <- cbind(df, response, logRT)
> df$logRT[df$logRT<5 | df$logRT >9] <- NA
> In my usual workflow I'd aggregate logRT over each factor and transpose to
> a wide format resulting in one row per subject to accomodate SPSS needs in
> GLM repeated measure procedure.
> Clearly running
> m <- lmer(logRT ~ A*B*C*D*response + (1|Subject), df)
> gives very different results from what I can get via SPSS anova and I'm
> guessing problem lies in how I specified the model in lmer call.
> Any help would be greatly appreciated.
> Blazej Mrozinski
> [[alternative HTML version deleted]]
> R-sig-mixed-models using r-project.org mailing list
More information about the R-sig-mixed-models