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:

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?

  • 3
    $\begingroup$ 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. $\endgroup$
    – Glen
    Commented Dec 18, 2017 at 17:38
  • 2
    $\begingroup$ 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)? $\endgroup$
    – Björn
    Commented Dec 18, 2017 at 21:29
  • 2
    $\begingroup$ 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. $\endgroup$
    – Niek
    Commented Dec 19, 2017 at 9:22
  • $\begingroup$ 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! $\endgroup$
    – yenats
    Commented Dec 19, 2017 at 10:14
  • 2
    $\begingroup$ 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. $\endgroup$
    – Niek
    Commented Dec 19, 2017 at 11:26

1 Answer 1


This is not an direct answer to my question almost 3 years ago. However, I found that there is no good way to use a "normal" glmm for this case. Instead, I opted for dynamic occupancy models where the response variable consists of two vectors, one for the "historic" and one for the "recent" plot occupancy. More on the topic can be found here: https://cran.r-project.org/web/packages/unmarked/unmarked.pdf

However, one constraint remained: so far, I could not figure how to deal with spatial autocorrelation in these models.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.