jeudi 11 avril 2019

How to do stepwise model with random effect (lme4 + lmerTest?)

I am trying to perform a stepwise model with a random effect, of which I can get a BIC value.

The lmerTest package said it works with lme4, but I can't get it to work. The error code is:

Error in $<-(*tmp*, formula, value = Terms) : no method for assigning subsets of this S4 class

I've read somewhere it might have something to do with the drop1, but I still didn't figure it out. I am also open to suggestions of other packages and functions.

Before, when trying the full.model <- lm ( ... everything worked. After changing to lmer, it didn't anymore.

The code I am using now:

full.model <- lme4::lmer(GYha ~ TM + soilPC1 + Welfare +plantPC1 + (1 | dorp),  data=data)

step.model<- lmerTest::step(full.model, direction="both",k=log(16))   # n=16

summary(step.model)

BIC(step.model)




Aucun commentaire:

Enregistrer un commentaire