Skip to contents

Function for calculate inverse distance weight.

Usage

spvar(yn, wtn)

Arguments

yn

The numerical vector of a response variable.

wtn

The spatial weight matrix.

Value

A value of spatial variance.

Details

The spatial variance formula is \(\Gamma = \frac{\sum_i \sum_{j \neq i} \omega_{ij}\frac{(y_i-y_j)^2}{2}}{\sum_i \sum_{j \neq i} \omega_{ij}}\)

References

Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693

Author

Wenbo Lv lyu.geosocial@gmail.com

Examples

y = c(42,56,73)
wt1 = inverse_distance_weight(1:length(y),1:length(y))
wt2 = matrix(1,ncol = length(y),nrow = length(y))
diag(wt2) = 0
spvar(y,wt1)
#> [1] 193.1
spvar(y,wt2)
#> [1] 241
var(y)
#> [1] 241