Learn R Programming

spacom (version 1.0-5)

WeightMatrix: Create spatial weighting matrices

Description

This step-1 function creates a matrix of spatial weights on the basis of a user-defined distance matrix, Kernel function, and bandwidth value. The distance matrix needs to specify a value for each of the possible $n by n$ binomials that correspond to n contextual units. It can be either symmetric or asymmetric. In principle, its diagonal, corresponding to the distance of each unit with itself, should be composed of zero values. A Kernel function proposed by default generates spatial weights that tend toward 1 for distances substantially lower than the bandwidth value, toward 0 for distances substantially higher than the bandwidth value and toward 0.5 for distances approaching the bandwidth value.

Usage

WeightMatrix(distance.matrix, bandwidth, kernel = NULL, moran = FALSE)

Arguments

distance.matrix
square matrix of dimension $n by n$, where $n$ is the number of contextual units.
bandwidth
scalar numeric value specifying the bandwidth $h$
kernel
function applied to the distance matrix. By default NULL, in which case the kernel function $$w_{ij}=f(d,h) = \left(\frac{1}{2}\right)^{d_{ij}^2/h^2}$$ is used, where $w_ij, d_ij, h$ are elements of the weight matrix $W$, of the distance matrix $D$ and the bandwidth $h$. User-supplied kernel functions have to take 2 arguments and return a matrix of the same dimension as the first argument.
moran
a logical value specifying whether the proximity weights matrix should have zeros in the diagonal. By default set to FALSE.

Value

A weights matrix of the same dimension as distance.matrix.

References

Elcheroth, G., Penic, S., Fasel, R., Giudici, F., Glaeser, S., Joye, D., Le Goff, J.-M., Morselli, D., & Spini, D. (2012). Spatially weighted context data: a new approach for modelling the impact of collective experiences. LIVES Working Papers, 19.

Examples

Run this code
# creating geographical proximity weight, with bandwidth h=50

data(d_geo) 
geow_50 <- WeightMatrix(distance.matrix=d_geo, bandwidth=50)

Run the code above in your browser using DataLab