# Random effects--mixed model

I have 2 study sites containing data from a species of wildlife. I am trying to evaluate resource selection use a use vs. availability analysis where used animal locations = 1 and random locations = 0. I used the following R code to address my question of interest:

results <- glmer(R0A1 ~ MP_Scaled * Season1 + MPHW_Scaled * Season1 + HW_Scaled * Season1 +
YP_Scaled * Season1 + AG_Scaled * Season1 + Shrub_Scaled * Season1 +
(1|ID) + (1|Site), data = turkey2nd, family = binomial,
glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 100000)))
summary(results)


I accounted for variation in unequal sample sizes for animals (i.e., number of telemetry locations/individual) by using (1|ID) but I also wanted to account for variability in habitat selection across study sites using (1|Site). I've always heard that you can specify study site as a random effect (and is typically encouraged by reviewers); however, I recently heard that I should include study site as a fixed effect to get the same inference as (1|ID) (i.e., adjusting for the effect of unequal sample sizes among sites on the marginal fixed effect estimate). The concern is that I have 73 individuals for (1|ID) but only 2 sites for (1|Site). What are some thoughts on this?

• One will not be able to estimate any meaningful random effect standard deviation out of a site factor with only two levels. If you choose to use it I would recommend treating it as a fixed effect. – usεr11852 Jul 28 '15 at 3:06
• This is interesting, will the model still be improved? Even If there are only two sites, should we still need to take account for the correlations of subjects (not iid) within the two sites? – Deep North Jul 28 '15 at 4:51
• Yet you never actually told us your question of interest. . . – StatsStudent Jul 29 '15 at 0:43

I will go ahead and agree with @usεr11852 that

One will not be able to estimate any meaningful random effect standard deviation out of a site factor with only two levels. If you choose to use it I would recommend treating it as a fixed effect.

If you do treat site as a random effect you are likely to get either (1) an estimate that the among-site variance is zero (hence effectively dropping the term from your model) or (2) an overestimate of the among-site variance (see e.g. this example on rpubs). Furthermore, even though you could in principle estimate a variation in intercept across the two sites (i.e. overall occupancy), it will be essentially impossible to estimate the variation in effects of different predictors on occupancy across the two sites, which is what you really want to know.

Actually, as your output here shows, what actually happens is that the site variable has a non-zero variance, but ID has zero variance. It's most likely better to take site out of the random effects and let the appropriate variance be assigned to ID.

Practically, to allow for differences in habitat selection across sites you should use the interaction of Site with your other predictors, i.e.

R0A1~Site*Season1*
(MP_Scaled+MPHW_Scaled+HW_Scaled+YP_Scaled+AG_Scaled+Shrub_Scaled)+
(1|ID)