Calculate the local Geary statistic for a given variable.
Usage
local_g(x, nb, wt, alternative = "two.sided", ...)
local_g_perm(x, nb, wt, nsim = 499, alternative = "two.sided", ...)
Arguments
- x
A numeric vector.
- nb
a neighbor list object for example as created by
st_contiguity()
.- wt
a weights list as created by
st_weights()
.- alternative
default
"two.sided"
. Should be one of"greater"
,"less"
, or"two.sided"
to specify the alternative hypothesis.- ...
methods passed to
spdep::localG()
orspdep::localG_perm()
- nsim
The number of simulations to run.
Value
a data.frame
with columns:
gi
: the observed statistice_gi
: the permutation sample meanvar_gi
: the permutation sample variancep_value
: the p-value using sample mean and standard deviationp_folded_sim
: p-value based on the implementation of Pysal which always assumes a two-sided test taking the minimum possible p-valueskewness
: sample skewnesskurtosis
: sample kurtosis
Examples
x <- guerry$crime_pers
nb <- st_contiguity(guerry)
wt <- st_weights(nb)
res <- local_g_perm(x, nb, wt)
head(res)
#> gi e_gi var_gi p_value p_sim p_folded_sim skewness
#> 1 0.8269073 0.01202468 4.708635e-06 0.40828962 0.384 0.192 0.108031563
#> 2 2.2675081 0.01190789 3.442762e-06 0.02335920 0.024 0.012 -0.022953469
#> 3 2.1065014 0.01195856 3.132039e-06 0.03516082 0.036 0.018 0.214384229
#> 4 -1.5578219 0.01193275 4.706590e-06 0.11927546 0.132 0.066 -0.064795417
#> 5 -1.2392682 0.01190442 5.660802e-06 0.21524620 0.224 0.112 -0.010932516
#> 6 -1.7438513 0.01198444 2.309388e-06 0.08118502 0.096 0.048 -0.008907957
#> kurtosis
#> 1 -0.28223473
#> 2 -0.02445925
#> 3 0.08371985
#> 4 -0.21852436
#> 5 -0.06798521
#> 6 -0.27354822