How to do it...

Use the following steps to analyze a GLMM:

  1. We will use the OrchardSprays dataset, which is included in R. It contains data for an experiment to assess the potency of various constituents of orchard sprays in repelling honeybees, using a Latin square design. The target variable will be a count variable, and the treatment effect will be treatment.rowpos and colpos should ideally be assumed to be random effects. First, we load the libraries:
library(lme4) library(emmeans) library(MASS) set.seed(10) 
  1. Let's ignore the random effects and fit this model using the regular GLM framework. Note that we specify family=poisson():
fixed_std_model = glm(decrease ~ treatment,family=poisson(),data=OrchardSprays) summary(fixed_std_model ...

Get R Statistics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.