The 1*dmin version shows one disconnected point (7). To avoid such problems,
use a slightly larger dmin value. In this case 1.0011188 is enough. The 4*dmin
version is very crowded. Many links are possible within a little more than 4 meters
around each point.
These connectivity matrices belong to class “nb”. To use them further we need to
convert them into another class called “listw”. The function doing this conversion is
called nb2listw().
In the simplest case, one of the binary matrices above can be directly converted as
follows (including a matrix-class representation of the connectivity matrix for
convenience, using function listw2mat()):
# Conversion of a "nb" object into a "listw" object
# Example: mite.thresh4 created above. "B" is for "binary"
mite.thresh4.lw <- nb2listw(mite.thresh4, style = "B")
print(listw2mat(mite.thresh4.lw)[1:10, 1:10], digits = 1)
This binary (unweighted) matrix could be used directly to create MEM variables
using the function scores.listw(); see below.
Now, if you want to apply weights onto a binary matrix (matrix A) on the basis of
Euclidean distances, you need two additional steps: (1) replace all values “1” in the
connectivity matrix by the corresponding Euclidean distances [function
nbdists()], and (2) define weights as a function of inverse distances in this
example, so that weights reflect the facility of exchange between sites (weights
may be different in other examples):
# Creation of a spatial weighting matrix W = Hadamard product of
# B and A.
# Replace "1" by Euclidean distances in the connectivity matrix
mite.thresh4.d1 <- nbdists(mite.thresh4, as.matrix(mite.xy))
# Weights as function of inverse distance
mite.inv.dist
function(x) 1-x/max(dist(mite.xy))
)
# Creation of spatial weighting matrix W. Argument "B" stands for
# "binary" but concerns the links themselves, not their weights
mite.invdist.lw
glist = mite.inv.dist,
style = "B")
print(listw2mat(mite.invdist.lw)[1:10, 1:10], digits = 2)
7.4 Eigenvector-Based Spatial Variables and Spatial Modelling
345
use a slightly larger dmin value. In this case 1.0011188 is enough. The 4*dmin
version is very crowded. Many links are possible within a little more than 4 meters
around each point.
These connectivity matrices belong to class “nb”. To use them further we need to
convert them into another class called “listw”. The function doing this conversion is
called nb2listw().
In the simplest case, one of the binary matrices above can be directly converted as
follows (including a matrix-class representation of the connectivity matrix for
convenience, using function listw2mat()):
# Conversion of a "nb" object into a "listw" object
# Example: mite.thresh4 created above. "B" is for "binary"
mite.thresh4.lw <- nb2listw(mite.thresh4, style = "B")
print(listw2mat(mite.thresh4.lw)[1:10, 1:10], digits = 1)
This binary (unweighted) matrix could be used directly to create MEM variables
using the function scores.listw(); see below.
Now, if you want to apply weights onto a binary matrix (matrix A) on the basis of
Euclidean distances, you need two additional steps: (1) replace all values “1” in the
connectivity matrix by the corresponding Euclidean distances [function
nbdists()], and (2) define weights as a function of inverse distances in this
example, so that weights reflect the facility of exchange between sites (weights
may be different in other examples):
# Creation of a spatial weighting matrix W = Hadamard product of
# B and A.
# Replace "1" by Euclidean distances in the connectivity matrix
mite.thresh4.d1 <- nbdists(mite.thresh4, as.matrix(mite.xy))
# Weights as function of inverse distance
mite.inv.dist
)
# Creation of spatial weighting matrix W. Argument "B" stands for
# "binary" but concerns the links themselves, not their weights
mite.invdist.lw
style = "B")
print(listw2mat(mite.invdist.lw)[1:10, 1:10], digits = 2)
7.4 Eigenvector-Based Spatial Variables and Spatial Modelling
345
