Absrtact: The nearer the point in the space sampling the corresponding variable may also be similar, this phenomenon is called spatial autocorrelation. Spatial autocorrelation can change people's judgments about the causes of certain things. For example, the number of species in a locality is high, and the number of species approaching is correspondingly higher, but this is not necessarily due to the fact that two ... The nearer the point in the space sampling the corresponding variable may also be similar, this phenomenon is called spatial autocorrelation. Spatial autocorrelation can change people's judgments about the causes of certain things. For example, the number of species in a locality is high and the number of species approaching is correspondingly higher, but this is not necessarily due to the fact that the environmental conditions are superior in two locations and are purely due to the closer space between two locations. The dependence of spatial relationships between points makes the data between points not independent. Therefore, it is necessary to examine the existence of spatial autocorrelation from the spatial relationship. The spatial autocorrelation test is expressed by Moran ' I. Moran ' s I is similar to the algorithm of Pearson correlation coefficient, but the relative degree of calculation is concerned with the point and point itself. In R's Ape package, there is a detailed description of Moran ' I. In order to test the significance of Moran ' I, the spatial statistician movement Randomization method obtains the 0 distribution of Moran ' I, and then the Moran ' I in each distance segment deviates significantly from the 0 distribution. In order to remove the spatial autocorrelation effect, the statistician has sent out the spatial autoregressive model, the SAR (spatial Auto regressive model), which can be conveniently implemented in R SPDEP. Of course, there are also numerous packages, such as the SAM package for macro Ecology data analysis. This is how to calculate and verify the detailed process of Moran ' I in the SPDEP package, and to call the SAR model for statistical inference. Hope to help the interested peers.
##################
Library (SPDEP)
# # To test whether Ntaxa has spatial autocorrelation
SETWD ("c:/one/")
Test0 <-read.csv ("Test.csv", Header = TRUE, row.names = 1)
Ntaxa <-Test0$ntaxa
# # Convert test DataSet to spatial format
Test <-test0[,c (1,2)]
Sptest <-spatialpoints (test, proj4string = CRS ("+proj=longlat +datum=wgs84"))
# # Calculates the nearest few neighbour of each point (here K = 1, which means that only one is counted)
NBK1 <-knn2nb (Knearneigh (sptest, k = 5, Longlat = TRUE)
# # converts NBK1 to spatial weight linkage object
SNBK1 <-make.sym.nb (NBK1)
### N.COMP.NB () finds the number of disjoint connected subgraphs
### in the graph depicted by nb.obj-a spatial Neighbours list object.
### View the number of adjacent points that are not connected to each point
N.COMP.NB (SNBK1) $NC
### View the links of each point
Plot (NB2LISTW (SNBK1), Cbind (Test$longitude, Test$latitude))
### Moran ' s test tests whether the dataset has significant spatial autocorrelation
### Moran ' s I test under Randomisation
Moran.test (Ntaxa, NB2LISTW (SNBK1))
### Moran ' s I correlograms
### par (Mfrow = C (1, 3))
Ntaxa. Moron.i <-Sp.correlogram (SNBK1, Ntaxa, order=6, method= "I", Zero.policy = TRUE)
Plot (Ntaxa. MORON.I)
### SAR Model
### saddlepoint approximation for global Moran ' I (Barndorff-nielsen formula)
Lm.morantest.sad (LM (ntaxa~1), NB2LISTW (SNBK1))
# # SACSARLM
COL.sacW.eig <-SACSARLM (ntaxa ~ Pre + Elev + factor (time) + factor (geology), Data =test0, NB2LISTW (SNBK1, style= "W"))
Summary (COL.sacW.eig, correlation=true)