# Mixed Model with categorical response variable

In a study on a bird species, I observe 558 locations. Each location is assigned one of 4 cases:

1. never occupied by the species (never)
2. occupied in the past but abandoned now (past)
3. occupied in the past and now (always)
4. not occupied in the past, but occupied now (current)

I have a set of explanatory variables (climate and landscape-structure). A simplified version of the data looks like this:

>bird.data
location_ID   case     region  temperature  forest.coverage
1             current  A       7.6          33
2             always   A       8.1          65
3             current  B       7.4          82
4             never    A       9.0          11
5             always   C       6.8          22
6             past     A       8.1          46
7             past     B       7.8          51
8             current  C       7.9          52
...           ...      ...     ...          ...

In R, I want to test weather the explanatory variables have an effect on the past and current occurence of the bird species. As a start, I want to compute univariate glmm using the lme4-package. region is supposed to act as a random factor. Similar to anova, I hope that this can help to show wether the four groups differ in their explanatory variables.

I would try something like lmer(case~temperature + forest.coverage + (1|region), data=bird.data) However, I am not familiar with modeling categorical response variables. Are there any rules to follow? Especially: where can I start in Order to determine a useful family for my case?

• It looks like you want to fit a mixed multinomial logistic model. This can be done with the glmer function in the lme4 package. lmer fits linear mixed regression models.
– Glen
Dec 18, 2017 at 17:38
• Do you want the 4 categories as your outcome, or occupied yes/no (in that case time would be a factor, if you model both party and present occupancy, or past occupancy could be a factor when modelling present occupancy)? Dec 18, 2017 at 21:29
• Your dependent variable seems to be the combination of two binomial variables (past occupancy (yes/no) and present occupancy (yes/no)). If you want to keep it simple and model these events separately you could transform your original variable into these two variables and start by modeling them separately with the glmer function (as suggested above) family = binomial. Edit: @Björn 's suggestion is also nice. This would require transforming your data into long format with a variable occupied (yes/no) and time (past/present). It really depends on what you want to know exactly.
– Niek
Dec 19, 2017 at 9:22
• Your guesses were right: the dependent variable is the combination of past occupancy (yes/no) and present occupancy (yes/no). However, I wanted to try and model all four categories in one. I thought, the output could be up to four groups differing significantly in their explanatory variable (something like groups a: current, always, b: past, c: never). A post-hoc test could reveal how the groups differ, then. I've not worked with glmer so far, so I will have a read on it - thank you! Dec 19, 2017 at 10:14
• Keep in mind that current occupancy might be related to past occupancy. By analyzing this as a single four-group variable you're making it very difficult (if not impossible) to take this relationship into account. I would give serious thought to Björn's suggestion as it will lead to a more flexible model that is (imo) easier to interpret.
– Niek
Dec 19, 2017 at 11:26