How to specify random effects for glmer I am analysing some data using a glmer and I want to figure out how to specify the random effects in the model. Basically, every subject underwent 10 trials for 4 consecutive days. I am wanting to investigate how environment, group and day affect the time on the 4 consecutive days. Here is a short summary of what the data looks like:
    Subject   Environment  Sex  Br_Status Group Trial Day Time
1   DamELC01      colony female       nbr  fnbr     1   1   60
2   DamELC01      colony female       nbr  fnbr     2   1   50
3   DamELC01      colony female       nbr  fnbr     3   1   15
4   DamELC01      colony female       nbr  fnbr     4   1   13
5   DamELC01      colony female       nbr  fnbr     5   1   60
6   DamELC01      colony female       nbr  fnbr     6   1   15
7   DamELC01      colony female       nbr  fnbr     7   1   26
8   DamELC01      colony female       nbr  fnbr     8   1    8
9   DamELC01      colony female       nbr  fnbr     9   1    8
10  DamELC01      colony female       nbr  fnbr    10   1    6

The current model set up that I have is:
glmer(Time~Environment*Group*Day + (1|Trial),  
              data=Exp2_ex, 
              family = Gamma(link = "log"),
              control=glmerControl(optimizer = "bobyqa")) 

I currently specified only Trial as a random effect but how would I include Subject as a random effect as well? I know they are crossed and I can include them as (1|Subject) + (1|Trial) , however I have seen multiple examples on here that they could be included together for example as (1+Trial|Subject) or (1|Trial:Subject)? Can someone possibly give me some insight?
 A: (1+Trial|subject) means estimating a fixed effect of Trial on Time separately for each subject. This does not seem very useful in terms of your research questions. Also, if you include this kind of term, you can't use Trial as random effect.
(1|Trial:Subject) means you get an interaction between the random effects of Trial and subject, basically asking whether the amount of Time variance attributable to Trial varies by subject. This may be something you want.
Not knowing your design in detail, I found myself wondering why you want a random effect of trial? Are trials meaningful clustering units in terms of Time? In other words, do you have  reason to believe that your "Time" observations are clustered within levels of "Trial" the way they are clustered within levels of "subject" as each subject is a different animal (right?)? Maybe elaborate a bit more on what exactly you want to know and what a trial entailed, but to me the most intuitive model based on the info you give would be
#either
model1<-glmer(Time ~ (1|subject) + (1|Day) + group*Environment,  data=Exp2_ex, 
              family = Gamma(link = "log"),
              control=glmerControl(optimizer = "bobyqa"))
#or
model2<-glmer(Time ~ (1|subject) + group*Environment*Day,  data=Exp2_ex, 
              family = Gamma(link = "log"),
              control=glmerControl(optimizer = "bobyqa"))

The former would give you fixed effects of group, environment, and their interaction, accounting for observations being clustered within subject and Day. The latter would give you fixed effects of group, environment, day, and their interactions, accounting for observations being clustered within subject.
