Standardising variables in mixed models I have rainfall and temperature data across multiple locations and I want to model yield as a function of these two. I know rainfall and temperature relationship is not linear i.e. there is a gain in yield first and then a decline with these two increasing. 
I did this:
dat$temp2 <- temp^2
dat$rain2 <- rain^2

dat.z <- scale(dat[,2:5], center = T)

lmer(yield ~ temp + temp2 + rain + rain2 + (1| loc), data = dat.z)

I wanted to ask do I have to standarise temp and rain first and then take the square or the above step is fine?
 A: A better way to model non-linear effects is using splines. This can be easily done in R using the splines package. For example, the code below specifies a natural cubic spline with three degrees of freedom for temp and rain:
library(splines)
fm <- lmer(yield ~ ns(temp, 3) + ns(rain, 3) + (1 | loc), data = dat)
summary(fm)

You can test whether the effect of temp is linear using:
gm <- lmer(yield ~ temp + ns(rain, 3) + (1 | loc), data = dat)
anova(gm, fm)

P.s., to decrease potentially multicollinearity issues between polynomial terms, typically you first standardize and then calculate the polynomials. However, a better way is to use orthogonal polynomials that resolve these issues. This is available in R using the poly() function, i.e., you could use:
lmer(yield ~ poly(temp, 2) + poly(rain, 2) + (1 | loc), data = dat)

A: +1 to Dimitri's answer because it is on the right track. Using splines to account for non-linearities is generally a better solution than immediately transforming our variables 
Some complementary points: 


*

*Kenward-Roger's approximation from pbkrtest or in general using to the package lmerTest probably is a better idea than using stats::anova from the lmer object. The tests in these packages are specifically design to deal with subtleties of mixed effects models. 

*Using generalised additive mixed models through gamm (or gamm4 - from the packages mgcv/gamm4 respectively) is a more stream-lined overall approach than using lmer and splines  as it has in-built checks on accessing and visualising the spline fit (e.g. see function gam.check from mgcv or check the package RLRsim that specifically focuses on questions like "is this smooth effect significantly different from a constant effect?"). 

*Two relevant papers on the matter of selecting relevant effects are: Scheipl et al. (2008) Size and power of tests for a zero random effect variance or polynomial regression in additive and linear mixed models and Greven and Kneib (2010) On the behaviour of marginal and conditional AIC in linear mixed models.

