Reputation: 2263
I have non-normal data (bacteria on fingers after touching surfaces with and without gloves) so using glmmPQL from the MASS package. I have one categorical predictor (Gloves), a repeated measurement variable (NumberContacts) and Participants who did the experiment gloved and ungloved so are crossed. I'd like to use the Participant variable as a random effect with random slope (but not intercept as they have 0 bacteria to start with). I can't figure out the syntax for random effects with random slope but not random intercept. Could you show me how to do this please?
So far I have:
require(MASS)
PQL <- glmmPQL(bacteria ~ Gloves+ NumberContacts, ~1|Participant,
family = gaussian(link = "log"),
#weights = varIdent(form = ~1 | NumberContacts),
#correlation = corAR1(NumberContacts),
data = na.omit(Ksub),
verbose = F)
Bacteria on fingers after each contact
Density plots of bacteria on fingers after each contact
Upvotes: 1
Views: 129
Reputation: 13118
See https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#model-specification, which notes that (0+x|group)
or (-1+x|group)
specifies "random slope of x within group: no variation in intercept."
The model specifications in the example below are equivalent:
library(MASS)
library(lme4)
fm1 <- lmer(Reaction ~ Days + (0 + Days | Subject), sleepstudy)
fm2 <- glmmPQL(Reaction ~ Days, random = ~ 0 + Days | Subject,
family = gaussian, data = sleepstudy)
Upvotes: 2