Learn R Programming

sdsfun (version 0.7.0)

spvar: spatial variance

Description

spatial variance

Usage

spvar(x, wt, method = c("cpp", "r"))

Value

A numerical value.

Arguments

x

A numerical vector .

wt

The spatial weight matrix.

method

(optional) The method for calculating spatial variance, which can be chosen as either cpp or r. Default is cpp.

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}}\)

Examples

Run this code
gzma = sf::read_sf(system.file('extdata/gzma.gpkg',package = 'sdsfun'))
wt1 = inverse_distance_swm(gzma)
spvar(gzma$PS_Score,wt1)

Run the code above in your browser using DataLab