spdep_distance_swm | R Documentation |
Constructs spatial weight matrices based on distance via spdep
package.
spdep_distance_swm(
sfj,
kernel = NULL,
k = NULL,
bandwidth = NULL,
power = 1,
style = "W",
zero.policy = TRUE
)
sfj |
An |
kernel |
(optional) The kernel function, can be one of |
k |
(optional) The number of nearest neighbours. Default is |
bandwidth |
(optional) The bandwidth, default is |
power |
(optional) Default is |
style |
(optional) |
zero.policy |
(optional) if |
five different kernel weight functions:
uniform:
K_{(z)} = 1/2
,for \lvert z \rvert < 1
triangular
K_{(z)} = 1 - \lvert z \rvert
,for \lvert z \rvert < 1
quadratic (epanechnikov)
K_{(z)} = \frac{3}{4} \left( 1 - z^2 \right)
,for \lvert z \rvert < 1
quartic
K_{(z)} = \frac{15}{16} {\left( 1 - z^2 \right)}^2
,for \lvert z \rvert < 1
gaussian
K_{(z)} = \frac{1}{\sqrt{2 \pi}} e^{- \frac{z^2}{2}}
For the equation above, z = d_{ij} / h_i
where h_i
is the bandwidth
A matrix
When kernel
is setting, using distance weight based on kernel function, Otherwise
the inverse distance weight will be used.
pts = sf::read_sf(system.file('extdata/pts.gpkg',package = 'sdsfun'))
wt1 = spdep_distance_swm(pts, style = 'B')
wt2 = spdep_distance_swm(pts, kernel = 'gaussian')
wt3 = spdep_distance_swm(pts, k = 3, kernel = 'gaussian')
wt4 = spdep_distance_swm(pts, k = 3, kernel = 'gaussian', bandwidth = 10000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.