[R-sig-ME] Looking for help in moving from a full factorial repeated measure anova to a LME model
Blazej Mrozinski
bl@zej@mrozin@ki @ending from gm@il@com
Thu May 31 13:37:28 CEST 2018
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)
anova(m)
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]]
More information about the R-sig-mixed-models
mailing list