I'm using generalized linear models to test for the effect of various predictors on some binomial data. My response is a binomial vector of successes and non-successes.
I want to test whether my categorical predictor of interest (P1) is a significant predictor of my response. However, there's another categorical variable (P2) that I want to take account of. Therefore I included it as random effect in my model, which seemed to have not much impact on whether P1 was significant or not:
mod1<-glmer(Response~P1+(1|P2),family=binomial)
mod0<-glmer(Response~1+(1|P2),family=binomial)
anova(mod0,mod1,test="Chisq")
However, reviewers have now asked me for more information on the effect of P2 - they think it will be important and want to know if it's significant or not. If I just test for an effect of P2 as a fixed effect on its own it would be significant, but I think this is just because there is come correlation with P1, not because it is important. Therefore I was thinking I could test whether P2 is a significant predictor within each level of P1, and tried to do this like so:
mod2<-glmer(Response~P2+(1|P1),family=binomial)
mod3<-glmer(Response~1+(1|P1),family=binomial)
anova(mod2,mod3,test="Chisq")
However, I'm worried that the formulas I'm using above are wrong, since I read this guidance on R mixed model formulas:
"Random effects are specified as e|g, where e is an effect and g is a grouping factor"
So should I actually be doing this:
mod4<-glmer(Response~P2|P1,family=binomial)
And if so, how do I test for significance?
As an additional question, my data is heavily overdispersed, but I notice I can't use quasibinomial in lme4. I've read about including an observation level random effect. Using my example above, is this the correct way to do so?
mod5<-glmer(Response~P2+(1|P1)+(1|obs),family=binomial)
mod6<-glmer(Response~1+(1|P1)+(1|obs),family=binomial)
anova(mod5,mod6,test="Chisq")
This doesn't seem to have any obvious affect on the results, so wasn't sure I was doing it right.
Many thanks