Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

step fails when random effects are eliminated by reduce.random #23

Closed
bbolker opened this issue Apr 18, 2019 · 1 comment
Closed

step fails when random effects are eliminated by reduce.random #23

bbolker opened this issue Apr 18, 2019 · 1 comment

Comments

@bbolker
Copy link
Contributor

bbolker commented Apr 18, 2019

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 ...

https://stackoverflow.com/questions/55638476/how-to-do-stepwise-model-with-random-effect-lme4-lmertest

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))

@runehaubo
Copy link
Owner

It only took us 1.5 years + 10 min to fix this issue :-) Thanks for reporting!

Cheers
Rune

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants