In my data frame I have my observations in blocks of time so in order to take the effect of year I decided to works with mixed effect model by specifying the year of sampling as random effect. This is a simple example of how I proceeded :
modele <- glmer(P_A ~ Tmax + (1 | year) ,
data = Data_Species_std_, family=binomial(link="logit"),
control=glmerControl(optimizer="bobyqa",
optCtrl=list(maxfun=1500000)))
where P_A
is presence-absence observations. From this model, I want to test the spatial autocorrelation of the residuals but I don't know if it is correct to extract the residual of this model resid(modele)
and perform the Moran's I test on it, since there is a temporal lag between my observations and so between my residuals. Otherwise, what is the best way to do such a test?