# Would including “year” as a categorical random effect remove a long-term trend in a mixed effects model?

I am trying to detect evidence of warming in a monthly temperature time series over a 20-year period by testing for a trend. I have precisely followed the method of Crawley (2013) The R Book, 2nd Edition pgs 798-799. In his linear mixed effects model for monthly temperatures he treats the explanatory variables time and linear trend as fixed effects, and year as a categorical random effect allowing for different intercepts for the different years. He then uses ANOVA to compare the full model (with trend explanatory variable) with a reduced version (i.e. without the trend explanatory variable).

A reviewer has questioned why year has been treated as a random effect and suggested that by doing so this would essentially remove a long-term trend. Can anyone clarify why it is correct to include year as a random effect and if by doing so this does or does not remove a trend?

Including by-Year random intercepts won't remove a long-term linear trend, but it may capture other non-linear trends not captured by the fixed-effects. See for this great explanation from Thierry Onkelinx discussing this problem, when Year has a quadratic trend. (One important difference: the time and trend fixed effects in your problem are handled by Year in the fixed-effects.)
There is the deeper question though about whether a model structure involving multiple terms for time (time, Year, trend) makes sense. I certainly can think of situations where this makes sense (e.g. student effort over the course of an academic year, where time represents the time within the year, trend models long-term trends over generations of students, and Year some other aspect of the sampling, perhaps the precise year within a generation of students), but it you could easily stumble onto a collinear or nonsensical model structure when you have multiple model parameters for closely related measurement variables.