0
$\begingroup$

I have temporal blocks in my data frame, so I took the effect of time dependency through a random intercept in a glmer model. Now I want to test the spatial autocorrelation in the residuals but I’m not sure if the test procedure based on the residual is the same as for the fixed-effect models since now I have time dependency. As follow, I show how I proceeded:

library(lme4)
library(ape)
GLMM_MODEL <- glmer(P_A ~ Tmax + (1 | year) , 
                data = Data, family=binomial(link="logit"),
                control=glmerControl(optimizer="bobyqa",
                                     optCtrl=list(maxfun=150000)))

#SPATIAL AUTOCORRELATION TEST 
    Data.dists <- as.matrix(dist(cbind(Data$X, Data$Y))) #IN UTM
    Data.dists.inv <- 1/Data.dists
    diag(Data.dists.inv) <- 0
    RESIDUAL <- residuals(GLMM_MODEL, type="deviance")
    MORAN_TEST <- Moran.I(RESIDUAL, Data.dists.inv)
$\endgroup$
3
  • $\begingroup$ Testing on deviance residuals is maybe not ideal. I would recommend using rdrr.io/cran/DHARMa/man/testSpatialAutocorrelation.html $\endgroup$ Commented Feb 22, 2021 at 7:53
  • $\begingroup$ @Florian Hartig thank you very much for your suggestions. Can you explain more why the choice of randomized residuals from DHARMa is a better choice than deviance residuals? $\endgroup$
    – user1988
    Commented Feb 23, 2021 at 3:54
  • $\begingroup$ Because deviance residuals are not homogenous, see intro of the DHARMa vignette $\endgroup$ Commented Feb 23, 2021 at 11:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.