Spatial autocorrelation test based on global Moran'I Index.
Arguments
- sfj
An
sf
object or vector object that can be converted tosf
bysf::st_as_sf()
.- wt
(optional) Spatial weight matrix. Must be a
matrix
class. Ifwt
is not provided,geocomplexity
will use a first-order queen adjacency binary matrix viasdsfun
package.- alternative
(optional) Specification of alternative hypothesis as
greater
(default),lower
, ortwo.sided
.- symmetrize
(optional) Whether or not to symmetrize the asymmetrical spatial weight matrix wt by: 1/2 * (wt + wt'). Default is
FALSE
.
Value
A list with moran_test
class and result stored on the result
tibble.
Which contains the following information for each variable:
MoranI
observed value of the Moran coefficient
EI
expected value of Moran's I
VarI
variance of Moran's I (under normality)
ZI
standardized Moran coefficient
PI
p-value of the test statistic
Note
This is a C++
implementation of the MI.vec
function in spfilteR
package,
and embellishes the console output.
The return result of this function is actually a list
, please access the result
tibble using $result
.
The non-numeric columns of the attribute columns in sfj
are ignored.
Examples
econineq = sf::read_sf(system.file('extdata/econineq.gpkg',package = 'geocomplexity'))
moran_test(econineq)
#> *** global spatial autocorrelation test
#> --------------------------------------------------------------------
#> Variable MoranI EI VarI zI pI
#> ----------- ------------- ----------- ---------- ------- -----------
#> Gini 0.42878*** -0.003012 0.001409 11.5 6.25e-31
#>
#> Induscale 0.290457*** -0.003012 0.001409 7.819 2.658e-15
#>
#> IT 0.633565*** -0.003012 0.001409 16.96 7.987e-65
#>
#> Income 0.554989*** -0.003012 0.001409 14.87 2.684e-50
#>
#> Sexrat 0.3819*** -0.003012 0.001409 10.26 5.585e-25
#>
#> Houseown 0.456893*** -0.003012 0.001409 12.25 8.026e-35
#>
#> Indemp 0.436889*** -0.003012 0.001409 11.72 4.992e-32
#>
#> Indcom 0.360323*** -0.003012 0.001409 9.681 1.821e-22
#>
#> Hiedu 0.735328*** -0.003012 0.001409 19.67 1.863e-86
#> --------------------------------------------------------------------
#>