makeneighborsw() create a spatial weight matrix based on a given number of nearest
neighbors (option "neighbor" by default), based on a threshold distance (option method="distance")
or both these 2 methods.
a matrix of spatial coordinates
"neighbor" by default, "distance" or "both"
number of nearest neighbors
if cum=TRUE, W is the sum of spatial weight matrix based on k nearest neighbours (for k < m; if FALSE W is the spatial weight matrix based only on m^th nearest neighbours
In the case of method="neighbor", for each site, we order the other sites by their distance from this site. If cum=TRUE, for i, if j is among the m^th nearest sites, then :
If cum=FALSE, for
is the m^th nearest site, then :
In case of ties, the nearest neighbour is randomly chosen.
In the case of method="distance", if site i is seperated from j by a distance lower or equal to a given threshold :
In the case of method="both" W must verify the two first conditions.
A spatial weight matrix of size n x n
This function is not optimised for large dataset. User could find similar functions in
knearneigh). However, these functions
don't offer the possibility to use the two criteria in the same time. Moreover, an
makeneighborsw is that the result is included in a matrix object
whereas most of functions of GeoXp use the
nb structure for spatial weight matrix.
An issue is to use the
mat2listw function and then selecting the
nb part, like the
in the examples.
Aragon Y., Thomas-Agnan C., Ruiz-Gazen A., Laurent T., Robidou L.
Thibault Laurent, Anne Ruiz-Gazen, Christine Thomas-Agnan (2012), GeoXp: An R Package for Exploratory Spatial Data Analysis. Journal of Statistical Software, 47(2), 1-23.
Roger S.Bivand, Edzer J.Pebesma, Virgilio Gomez-Rubio (2009), Applied Spatial Data Analysis with R, Springer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## # data auckland data(auckland) coords <- cbind(auckland$Easting[1:10],auckland$Northing[1:10]) # matrix based on 5 nearest neighbors W<-makeneighborsw(coords,method="neighbor",m=3) # matrix based on a threshold distance W1<-makeneighborsw(coords,method="distance",d=20) # matrix based on the two methods W2<-makeneighborsw(coords,method="both",m=3,d=20) # representation of the 3 spatial weight matrices op<-par(mfrow=c(2,2)) plot(mat2listw(W),coords,col="lightblue1",main="neighbor") plot(mat2listw(W1),coords,col="lightblue2",main="distance") plot(mat2listw(W2),coords,col="lightblue3",main="both") par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.