Learn R Programming

spacom (version 0.9-3)

WeightMatrix: Create weight matrices

Description

Creates a weight matrix corresponding to a given distance matrix, bandwidth and kernel function for spatially weighted multilevel analysis.

Usage

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

Arguments

distance.matrix
square matrix of dimension $n\times 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 $\mathbf{W}
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.

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