# Removing spatial autocorrelation (SAC) using Moran's Eigenvectors and predict distribution?

I successfully managed to incorporate moran's eigenvectors as predictor to my species distribution model using GLM (logit). I followed Dormann et al. (2007) and the appendix. I think I got corrected statistics in the moran.test() of model residuals as the p-value increases.

normal model:

``````Moran I test under randomisation

data:  residuals(model)
weights: priclus.listw

Moran I statistic standard deviate = 7.5632, p-value = 1.966e-14
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance
0.264335666      -0.007633588       0.001293086
``````

spatial model:

``````Moran I test under randomisation

data:  residuals(model)
weights: priclus.listw

Moran I statistic standard deviate = 1.5572, p-value = 0.05972
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance
0.045968614      -0.007633588       0.001184932
``````

Now I would like to compare te results of evaluate() and the predictions between the normal model and the spatial model. For the spatial model I get an error: "there are different length for the variables".

``````> summary(priclus8<- glm(pb_train ~ gesteine + schnee_tag_1 + rs_hospso, family= binomial(link="logit"), data=envtrain))

Call:
glm(formula = pb_train ~ gesteine + schnee_tag_1 + rs_hospso,
family = binomial(link = "logit"), data = envtrain)

Deviance Residuals:
Min        1Q    Median        3Q       Max
-2.76552  -0.18741  -0.00449   0.34032   2.03205

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)  75.89890   20.21051   3.755 0.000173 ***
gesteine1     2.05287    0.55421   3.704 0.000212 ***
schnee_tag_1 -0.03328    0.01685  -1.975 0.048223 *
rs_hospso    -1.56444    0.37856  -4.133 3.59e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 387.96  on 284  degrees of freedom
Residual deviance: 129.56  on 281  degrees of freedom
AIC: 137.56
Number of Fisher Scoring iterations: 7

> sevm1 <- fitted(ME(pb_train ~ gesteine + schnee_tag_1 + rs_hospso, data=envtrain, family= binomial(link="logit"),listw=ME.listw))

> summary(priclus8_mem<- glm(pb_train ~ gesteine + schnee_tag_1 + rs_hospso+ I(sevm1), family= binomial(link="logit"), data=envtrain) )

Call:
glm(formula = pb_train ~ gesteine + schnee_tag_1 + rs_hospso +
I(sevm1), family = binomial(link = "logit"), data = envtrain)

Deviance Residuals:
Min       1Q   Median       3Q      Max
-3.6095  -0.1415  -0.0025   0.0784   2.5099

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)   102.50545   28.27283   3.626 0.000288 ***
gesteine1       0.80346    0.79373   1.012 0.311417
schnee_tag_1   -0.06435    0.02448  -2.628 0.008586 **
rs_hospso      -1.99483    0.52879  -3.772 0.000162 ***
I(sevm1)vec8   35.86461    8.38806   4.276 1.91e-05 ***
I(sevm1)vec25 -46.33209    8.82448  -5.250 1.52e-07 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 387.959  on 284  degrees of freedom
Residual deviance:  69.198  on 279  degrees of freedom
AIC: 81.198

Number of Fisher Scoring iterations: 8

>e.priclus8_mem<-evaluate(test_pres_val, test_abs_val, priclus8_mem)

#Error in model.frame.default(Terms, newdata, na.action = na.action,
#xlev = object\$xlevels) :  Variablenlängen sind unterschiedlich
#120 rows but variables found have 285 rows

> plot(pclus8_mem<-predict(env_data, priclus8_mem, type="response"), main="GML priclu8_mem")

#Error in model.frame.default(Terms, newdata, na.action = na.action,
#xlev = object\$xlevels):Variablenlängen sind unterschiedlich (gefunden
#für 'I(sevm1)')
``````

Is this error caused by points with no neighbour? I used zero.polycy=TRUE to accept no neighbours in the nb object.

What else could be the problem?

I am new in the matter and can not get any further here.

• How are you getting a valid Moran's-I on a binominal process? The statisics derivation of the mean on [0,1] would be quite spurious. Is the autocorrelation based on the residual error or an estimated odds ratio? At this point one wonders why you dont just fit an autoregressive model using an MCMC. This would provide the evaluation framwork you are after, as well as a direct measure of the uncertainty, which is not possible using a Moran's eiganvector approach. – Jeffrey Evans Mar 29 '17 at 16:18
• Thank you. Yes I tested the model residuals for autocorrelation. Do you have any reference or some tutorial for an autoregressive model using an MCMC, so that i can see the workflow? The aim is also to generate a surface of the spatial model to have the distibution of the species. – parallax Mar 29 '17 at 17:57
• No, I do not have a tutorial but there is a large body of literature on SAR and CAR models. Spatial filtering is a powerful method but is more suited to spatial inference and is likely unnecessary in the case of an SDM. Have you explored Poisson Point Process Models? Warton & Shepherd (2010) have a great paper on this. citeseerx.ist.psu.edu/viewdoc/… – Jeffrey Evans Mar 29 '17 at 18:53
• Point Process Models are also an interesting approach, thak you. I'll chek how to use it. – parallax Apr 3 '17 at 9:16