# How to test the effect of a grouping factor that should be random to account for repeated measures?

Experimental plan: several species of animals were observed for a year, but not regularly (some months have many observations, others have less). All individuals belonging to the same species were housed together in the same terrarium (unequal number of individuals per species). The response variable is the number of awake individuals per terrarium (i.e. per species). The year was divided in 3, unequal, periods as follows: treatment / control / treatment.

I want to determine the effect of the Period (treatment / control), of the Species (12 in total), and of their Interaction on the proportion of awake animals.

I wanted to use a GLMM with a binomial error distribution. The problem is that I have repeated measures per species: should I account for that by using Species as a random effect to avoid pseudoreplication, or do I need Species to be a fixed effect because I want to directly test its effect on my response? Would adding the Date (as an integer: number of days since the beginning of the experiment) to the model control for these repeated measures (but I can't use it as a random effect because it is continuous, and it makes my model too complex to converge when integrated as a fixed effect), or should I sum the response per month to use Month as a random effect ordered factor.

I am stuck here and would like to avoid taking a mathematically erroneous approach. Could you advise me please? Thank you in advance for your generous help!

There are a few issues here.

• your design is intrinsically pseudo-replicated: "All individuals belonging to the same species were housed together in the same terrarium". That means that it is impossible (by statistical means) to distinguish an effect of differences among terraria from differences among species. You should be up-front about this in the description of your set-up/discussion of your results (i.e., you are going to assume for scientific purposes that the differences among terraria are small so that you can attribute the observed effects to intrinsic differences among species).
• You can test the effect of Species on the response whether it is a fixed or a random effect (see the GLMM FAQ for advice on significance tests of random effects). What you can't do under the frequentist paradigm is test the significance of particular contrasts, e.g. whether one species is significantly different from the rest; all you can do is test whether the overall among-species variance in awakeness is significantly different from zero. You can look at the predicted effects for each species (conditional modes) and get a measure of their uncertainty (conditional variances/standard deviations), but can't do formal hypothesis tests on them. In general, treating species as a random effect will probably get you more reliable answers (because you are sharing information across species).
• controlling for the effect of time (either by date or by month) is probably a good idea, but doesn't address the (pseudo)replication issue. A random effect of month will model irregular month-to-month variation; a fixed effect of date will model trends in time (in principle, you could include both in the model).

I would probably try

cbind(num_awake, num_asleep) ~ period + (1|month) + (1 + period | Species)


with family = binomial.

the (1 + period|Species) term estimates the variation among species in their probability of being awake, and the variation in the difference between periods among species.