Dear list,
I am currently working on modelling species distribution and try to account
spatial autocorrelation. I use R and I successfully managed to incorporate
moran's eigenvectors as predictor to my species distribution model using
GLM (logit). I followed Dormann et al. (2007
<https://www2.unil.ch/biomapper/Download/Dormann-EcoGra-2007.pdf>) and the
appendix
<http://www.ecography.org/sites/ecography.org/files/appendix/e5171.pdf>. I
think I got corrected statistics in the moran.test() of model residuals as
the p-value increases. Also the AIC score indicates a better spatial model.
*Normal model glm:*
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
*See the summary for both models below:*
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
Now I would like to compare the 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".
I also want to plot the SAC-corrected predicted model to visualize the
distribution.
#Error in model.frame.default(Terms, newdata, na.action = na.action,
#xlev = object$xlevels) : Variablenl?ngen sind unterschiedlich
#(gefunden f?r 'I(sevm1)') In addition: Warning message:'newdata' had
#120 rows but variables found have 285 rows
#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 also read Bivand et al. (2008): Applied Spatial Data Analysis with R and
Borcard et al. (2011): Numerical Ecology with R. The given examples always
refer to vector data but I am working with raster data?
I am new in the matter and cannot get any further here. I have certainly
overlooked something or misunderstood. Any help and further reading is
appreciated!
Many thanks,
Patrick