When all random effects are removed at the reduce.random stage, the resulting object is of class lm rather than merMod, and can't be converted to an lmerModLmerTest object. At a quick glance it looks like older versions may have had a fix for this case, i.e. passing the resulting object on to stats::step ...
set.seed(101)
test <- data.frame(TM = factor(rep(rep(c("org","min"),each=3),3)),
dep = runif(18,0,20),
ind = runif(18,0,7),
dorp = factor(rep(1:3,each=6)))
library(lmerTest)
full.model <- lmer(dep ~ TM + ind + (1 | dorp), data=test)
step(full.model)
Error in as_lmerModLmerTest(model) :
model not of class 'lmerMod': cannot coerce to class 'lmerModLmerTest
step.model<- lmerTest::step(full.model, direction="both",k=log(16))
When all random effects are removed at the
reduce.random
stage, the resulting object is of classlm
rather thanmerMod
, and can't be converted to anlmerModLmerTest
object. At a quick glance it looks like older versions may have had a fix for this case, i.e. passing the resulting object on tostats::step
...https://stackoverflow.com/questions/55638476/how-to-do-stepwise-model-with-random-effect-lme4-lmertest