I have data on the diversity of pathogens infecting a particular host species across latitudes. The design involved collecting 20 individuals at 3 sites within 4 locations of different latitudes, therefore I have 20 individuals, nested within 3 sites, nested within 4 locations.
Given that my pathogen diversity data is count data with many zeros, which is why I have been exploring using using a GLMM with the lme4::glmer
command in R to analyze the data. For the analysis I want to treat latitude as a numeric fixed factor and site as a random factor nested with location.
For my full model I have set up my command as follows:
glmer(pathogen.richness~latitude+(site|location),data=my.data,
family="poisson")
Is this the correct syntax for what I described?
Thanks!
Random effects, like fixed effects, can either be nested or not; it depends on the logic of the design.
Nested random effects are when each member of one group is contained entirely within a single unit of another group. The canonical example is students in classrooms; you may have repeated measures per student, but each student belongs to a single classroom (assuming no reassignments).
You probably want
glmer(pathogen.richness~latitude+(1|location/site),
data=my.data,family="poisson")
However, you're probably going to run into problems trying to fit a random effect of location to only 4 locations, so you may prefer
glmer(pathogen.richness~latitude+location+(1|location:site),
data=my.data,family="poisson")
(even though location is conceptually a random effect, it may be more practical to fit it as a fixed effect).
Don't forget to check for overdispersion; one way to handle this is to add an observation-level random effect:
transform(my.data,obs=factor(seq(nrow(mydata)))
update(prev_model,.~.+(1|obs))
See the GLMM FAQ and http://glmm.wdfiles.com/local--files/examples/Banta_2011_part1.pdf for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With