This vignette gives a few examples on how to create different spatial
weights matrices using the SDPDmod package.
A spatial weights matrix is an N×N non-negative matrix, where N is the size of the data set. The elements of the spatial matrix W, wij are non-zero if i and j are considered to be neighbors and zero otherwise. Since unit i can not be a neighbor to itself, the diagonal elements of the spatial weights matrix are zero, i.e. wij=0.
Data on German districts and distances between district’s centroids
in meters are included in the SDPDmod package and are used
for the examples.
wij={1,iandjhave a shared boundary0,otherwise
wij={1,if unitjis one of theknearest neighbor ofi0,otherwise
wij=d−αij dij - distance between units i and j, α - positive exponent
    ## inverse distance no cut-off
    W_inv1 <- InvDistMat(distMat = gN3dist) 
    ## inverse distance with cut-off 100000 meters
    W_inv2 <- InvDistMat(distMat = gN3dist, distCutOff = 100000) 
    gN3dist2 <- gN3dist/1000 ## convert to kilometers
    ## inverse distance with cut-off 100 km
    W_inv3 <- InvDistMat(distMat = gN3dist2, distCutOff = 100)  
    ## inverse distance with cut-off 200km and exponent 2
    W_inv4 <- InvDistMat(gN3dist2, 200, powr = 2) wij=exp(−αdij) dij - distance between units i and j, α - positive exponent
    ## Exponential distance no cut-off
    W_exp1 <- ExpDistMat(distMat = gN3dist) 
    ## Exponential distance with cut-off 100000 meters
    W_exp2 <- ExpDistMat(distMat = gN3dist, distCutOff = 100000) 
    gN3dist2 <- gN3dist/1000 ## convert to kilometers
    ## Exponential distance with cut-off 100 km 
    W_exp3 <- ExpDistMat(gN3dist2, 100) 
    ## Exponential distance with cut-off 100 km
    W_exp4 <- DistWMat(gN3dist2, 100, type = "expo") 
    all(W_exp3==W_exp4)
#> [1] TRUE
    ## Exponential distance with cut-off 200 km and exponent 0.001
    W_exp5 <- ExpDistMat(gN3dist2, 200, expn = 0.001) wij={(1−(dijD)p)p,0≤dij≤D0,dij≥D dij - distance between units i and j, p - positive exponent, D - distance cut-off
    ## Double-Power distance no cut-off, exponent 2
    W_dd1 <- DDistMat(distMat = gN3dist) 
    ## Double-Power distance with cut-off 100000 meters, exponent 2
    W_dd2 <- DDistMat(distMat = gN3dist, distCutOff=100000) 
    gN3dist2 <- gN3dist/1000 ## convert to kilometers
    ## Double-Power distance with cut-off 100 km 
    W_dd3 <- DDistMat(gN3dist2, 100) 
    ## Double-Power distance with cut-off 100 km
    W_dd4 <- DistWMat(gN3dist2, 100, type = "doubled") 
    all(W_dd3==W_dd4) 
#> [1] TRUE
    ## Double-Power distance with cut-off 200km and exponent 3
    W_dd5 <- DDistMat(gN3dist2, 200, powr = 3) wnormalizedij=wij/N∑j=1wij