I’m using the MASS package to create ordered contrasts (i.e., compare level 3 to level 2; level 2 to level 1). However, I am running into an error when I try to use lmer_alt() and uncorrelated random effects with this coding. Do you have any idea why this might be? I’m attaching a reproducible example below.
Subj <- rep(1:10, each = 10)
Item <- rep(1:10, times = 10)
IV1 <- rep(1:5, times = 20)
DV <- rnorm(100)
library(data.table)
data <- as.data.table(cbind(Subj, Item, IV1, DV))
data$Subj <- as.factor(data$Subj)
data$Item <- as.factor(data$Item)
data$IV1 <- as.factor(data$IV1)
library(MASS)
contrasts(data$IV1) <- contr.sdif(5)
library(lme4)
library(afex)
mafex <- lmer_alt(DV ~ IV1 + (1 + IV1||Subj) + (1|Item), data = data)
I get the following error:
Error in terms.formula(frml) : invalid model formula in ExtractVars