# Nesting random effect within fixed effect, with additional nested random effect. Nominal logistic

Very new to R so please pardon my naivety. I am trying to run a sort of mixed effects nominal logistic regression model with my insect response data. I have 2 rearing treatments (hot and cold) and 3 replicates within each treatment (1,2,3,4,5,6) with data (1/0) for both males and females. Each individual was tested at up to 5 different temperatures. To start I am trying to compare responses by Sex, so comparing females across the 2 treatments. Currently I have this:

RandomFemales<-glmer(Called~ Treatment + Temp + Temp*Temp + Temp*Treatment + Temp*Temp*Treatment + DaysFromEclose + Temp*DaysFromEclose +Temp*Temp*DaysFromEclose + (1|Treatment/Rep) + (1|Rep/ID), data = Females, family=binomial, control = glmerControl(optimizer = "bobyqa"))

where temp*temp accounts for the quadratic shape of their activity curves across temperatures. DaysFromEclose is more or less time, since individuals were tested across several days.

Replicates are specific to the treatments (ie, 2,4,6 are Hot, 1,3,5 are Cold), so I assumed replicate would have to be nested within treatment, and individual ID nested within replicate to account for differences in individual response rate. The problem is that now it seems that Treatment is being treated as a random effect which it is not. Any thoughts? thank you! Update RE warnings:

Warning messages:
1: In optwrap(optimizer, devfun, start, rho$lower, control = control, : convergence code 1 from bobyqa: bobyqa -- maximum number of function evaluations exceeded 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 0.235779 (tol = 0.002, component 1) 3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control\$checkConv,  :
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?
• Does that model converge without warnings ? The random structure does not makes sense. If ID is nested in Rep and Rep is nested in Treatment then you probably want Treatment/Rep/ID unless there is crossing . But then you have Treatment as a fixed effect, so that looks like a problem. I don't see why Treatment should be random, nor Rep for that matter, though I'm happy to be convinced otherwise :) – Robert Long Jun 30 '20 at 19:21
• sorry for confusion! Treatment should not be random! Replicate should be because each replicate was from a different rearing incubator where there may have been influences we could not account for. I have updated the original post with the warnings – Anthony Macchiano Jun 30 '20 at 19:31
• "Replicate should be [random] because each replicate was from a different rearing incubator where there may have been influences we could not account for". I need convincing that that is a reason for it to be random and not fixed. That reason might be applied to it being a fixed factor, particularly when you have only 3 of them. Also, do the warnings come from the model with or without Treatment as random ? – Robert Long Jun 30 '20 at 19:44