I’m interested in understanding if a count variable (abundance of insects caught in traps) differs between sites (I’ll call this “difference effect”), and assessing if this difference may appear in one area but not another one. My experimental design is:

- 2 areas (categorical: area_1; area_2)
- 5 transects (3 in one area and 2 in the other one) (categorical: "A";"B";"C")
- 10 sites (2 sites for each transect) (dummy: 0;1)
- 80 traps (8 in each site) (counts)

My response variable is sites, and my predictors are groups of insects, each of them a count variable.

I can only compare sites within transects (I cannot compare site 1 in transect A to site 0 in transect B; not sure if this means sites are paired), and, as the areas are distinct from one another, I cannot say the difference effect is the same in both areas, I have to separate this effect somehow.

I’m running logistic regressions in order to know if there is a “difference effect” (a group of insects being more abundant) in one of the sites compared to the other one (within transects and in the same area). It is necessary that transects be integrated as random effects in my models. I can think of two options for modelling this: one option is to run separate analysis for each area, like so:

model_area_1 <- glmer(Sites ~ group1 + group 2 + group3 + group4 + (1|Transect),
family = binomial(link = "logit"), data = df_area_1)

model_area_2 <- glmer(Sites ~ group1 + group 2 + group3 + group4 + (1|Transect),
 family = binomial(link = "logit"), data = df_area_2)

The first model has N = 48 and group Transect = 3, while the second one has N = 32 and group Transect = 2.

In the other option, transects would be included as nested within areas in one model:

model_both_areas <- glmer(Sites ~ group1 + group 2 + group3 + group4 + (1|Area/Transect),
 family = binomial(link = "logit"), data = df_both_areas)

This model has N = 80 and groups Transect/Area = 5 and Area = 2.

I have two questions:

1) is one of the options better than the other? (maybe I should compare them using AIC?). Again, my objective is to understand if a group of insects is more abundant in one site instead of the other, taking into consideration that this might happen in one area, but not in the other.

2) is there any reason for me to use another link function? I saw this answer which says that extensive variables should be dealt with using log link function, so I think this is correct in my models.

Hope this question is pertinent and I have been clear.

  • 1
    $\begingroup$ Could you elaborate on why your outcome is sites and not counts of insects? Seems like it should be the other way around $\endgroup$ Commented Jul 29, 2016 at 21:06
  • 1
    $\begingroup$ Thanks for commenting. My outcome is site because I'm trying to assess if a group of insects is more prone to be on site 0 than 1 (or vice-versa). I'm using logistic regression as if it was a discriminant function. $\endgroup$
    – Lfppfs
    Commented Jul 29, 2016 at 22:09

1 Answer 1


Assuming that your outcome really is binary:

You don't have enough areas to model it as a random effect so the 3rd model is not viable.

However you can run model 1 and 2 on the same dataset with the addition of Area as a fixed effect.

This will have the advantage of giving more statistical power than individual models for each area.

glmer(Sites ~ group1 + group 2 + group3 + group4 + Area + (1|Transect), family = binomial(link = "logit"), data = df_both_areas)

The logit link has the benefit of providing easily interpretable results, so I would keep that.

  • $\begingroup$ Thank you for your answer. But could you explain why I don't have enough areas to model as random effects? Residual DFs are the same on the model I thought of and on the one you mentioned. (Btw, I voted on your answer but I still haven't enough reputation for the score to appear) $\endgroup$
    – Lfppfs
    Commented Jul 30, 2016 at 12:17
  • $\begingroup$ You have 2 areas, right ? The model assumes that random effects are multivariate normal, but you can't expect to estimate a variance for something with only 2 observations. Se here: glmm.wikidot.com/faq "Treating factors with small numbers of levels as random will in the best case lead to very small and/or imprecise estimates of random effects; in the worst case it will lead to various numerical difficulties such as lack of convergence, zero variance estimates, etc." $\endgroup$ Commented Jul 30, 2016 at 14:22
  • $\begingroup$ Ok, I understand that, but if I leave Area as a fixed effect, that's still going to happen, isn't it? $\endgroup$
    – Lfppfs
    Commented Jul 30, 2016 at 14:45
  • $\begingroup$ No, it won't. As a fixed effect only, there is no random component for it. $\endgroup$ Commented Jul 30, 2016 at 14:51

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.