pitakakariki / simr

Power Analysis of Generalised Linear Mixed Models by Simulation
69 stars 19 forks source link

Error in powerSim in simr #159

Open nataliemastick opened 5 years ago

nataliemastick commented 5 years ago

Hi there, I have been having a reoccurring error with simr. I want to test a random effect in a powerSim. My model looks like this: mod<-glmer(eggcount~year+month+age.class+(1|family:ID), data=eggdata, family=poisson)

All of the help files to show how to do this suggest to test it first in doTest. The suggested code was doTest(mod, random()). I would then follow it with powerSim(mod, test=random()). However, I haven't gotten past the doTest stage, as every time I try it I get the following error: Error in exactRLRT(.) : Invalid < m > specified.

Though when I try to specify my "m", the reduced model with just the random effect, I get an error that there are unused arguments. I have tried inputting my "m" in many different ways, and it is always an unused argument.

Can anyone help me get around this issue?

pitakakariki commented 5 years ago

I don't think any of the built-in tests can test a single random effect in a glmm (random() is only implemented for lmm's at the moment). Best option might be a user-specified test function:

# null model with no random effect
mod0 <- glm(eggcount~year+month+age.class, data=eggdata, family=poisson)

# user specified test function
f <- function(m) anova(m, mod0)$Pr[2]

doTest(mod, f)