Skip to contents

Formula: \(G = \sum_i \sum_{j \ne i} w_{ij} x_i x_j / \sum_i \sum_{j \ne i} x_i x_j\), \(E[G] = S_0/(n(n-1))\), and the randomisation variance of Getis and Ord (1992) built from \(S_0, S_1, S_2\) and the moments \(m_r = \sum_i x_i^r\): \(B_0 = (n^2-3n+3)S_1 - nS_2 + 3S_0^2\), \(B_1 = -[(n^2-n)S_1 - 2nS_2 + 6S_0^2]\), \(B_2 = -[2nS_1 - (n+3)S_2 + 6S_0^2]\), \(B_3 = 4(n-1)S_1 - 2(n+1)S_2 + 8S_0^2\), \(B_4 = S_1 - S_2 + S_0^2\). G is only interpretable for non-negative x, so negative input is rejected rather than silently returned.

Usage

Getisordg(x, W)

Arguments

x

Non-negative variable of length n.

W

n by n spatial weights; the diagonal is forced to zero.

Value

List with estimate (G), statistic, p_value, expected, var, S0, S1, S2, n, method.

References

Getis and Ord (1992), Geographical Analysis 24:189-206. Paywalled; the coded moments were read from Bivand and Ono's spdep, R/globalG.R and spweights.constants in R/utils.R. B1 uses spdep's B1correct = TRUE default (6 S0^2, not the 3 S0^2 of CrimeStat IV).

Examples

set.seed(1)
x <- runif(10, 1, 10)
W <- matrix(rbinom(100, 1, 0.3), 10, 10)
diag(W) <- 0
Getisordg(x, W)
#> $estimate
#> [1] 0.3420556
#> 
#> $statistic
#> [1] 0.91274
#> 
#> $p_value
#> [1] 0.3613793
#> 
#> $expected
#> [1] 0.3222222
#> 
#> $var
#> [1] 0.0004721726
#> 
#> $S0
#> [1] 29
#> 
#> $S1
#> [1] 31
#> 
#> $S2
#> [1] 350
#> 
#> $n
#> [1] 10
#> 
#> $method
#> [1] "Getis-Ord global G"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"