How to choose and correctly code random variables - glmer I am analysing some data with glmer (lme4). This is what the data looks like:
Animal_ID Environment    Sex Br_Status Group Day M_time
1  DamELC01      colony female       nbr  fnbr   1   26.1
2  DamELC01      colony female       nbr  fnbr   2   12.9
3  DamELC01      colony female       nbr  fnbr   3    8.3
4  DamELC01      colony female       nbr  fnbr   4    8.8
5  DamELC02      colony female       nbr  fnbr   1   32.5
6  DamELC02      colony female       nbr  fnbr   2   11.4

Each animal was tested over 4 consecutive days. Essentially, I am trying to find the effect of Group, Environment and Day on M_time. I have chosen Environment and Group as fixed factors, as well as Day to see whether the time improves from day to day. I used Animal_ID as a random effect as it is a repeated measure. This is what my original glmer set-up is:
mod1 <- glmer(M_time~Environment*Group*Day + (1|Animal_ID), 
              data=data, 
              family = Gamma(link = "log"),
              control=glmerControl(optimizer = "bobyqa")) 

I am now wondering whether Day should be included as a fixed variable and a random variable? If so, how should I include it in the model?

Your model is not estimable since you are including both Day as a random effect and as a fixed effect. Unless you have a further level of replication, which doesn't seem to be the case.
If you treat Day as a random effect you cannot test for possible day effects. Choose either one or the other approach.
Although the debate on random vs fixed effects is still going on, the general recommendation seems to be that for a variable with few levels or values, it is probably best to consider it fixed rather than random.
So in your case, if you are interested in possible day effects, you should not use random effects and the other way around.
