moranNP.randtest: Function to compute positive and negative parts of Moran's...

View source: R/moranNP.randtest.R

moranNP.randtestR Documentation

Function to compute positive and negative parts of Moran's index of spatial autocorrelation

Description

This function computes positive and negative parts of Moran's I statistic and provide a testing procedure using random permutations. The functions compute the Moran's eigenvector maps (MEM) and eigenvalues for the listw object. If alter = "greater", the statistic 'I+' is computed as the sum of the products between positive eigenvalues and squared correlations between x and associated MEMs. If alter = "less", the statistic 'I-' is computed as the sum of the products between negative eigenvalues and squared correlations between x and associated MEMs. If alter = "two-sided", both statistics are computed.

Usage

moranNP.randtest(
  x,
  listw,
  nrepet = 999,
  alter = c("greater", "less", "two-sided"),
  ...
)

Arguments

x

a vector with numeric data

listw

an object of class listw created for example by nb2listw

nrepet

an integer indicating the number of permutations used in the randomization procedure

alter

a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two-sided"

...

other arguments (e.g., p.adjust.method) to be passed to the as.krandtest function.

Value

An object of class randtest (for unilateral test) or krandtest (for bilateral test)

Author(s)

Stéphane Dray stephane.dray@univ-lyon1.fr

References

Dray, S. (2011). A new perspective about Moran's coefficient: spatial autocorrelation as a linear regression problem. Geographical Analysis, 43, 127-141.

See Also

moran.randtest

Examples

if(require("ade4", quietly = TRUE)  & require("spdep", quiet = TRUE)){
data(mafragh)
tests <- moranNP.randtest(mafragh$env[,1], nb2listw(mafragh$nb),
 alter = "two-sided", p.adjust.method = "holm")
tests
moran.randtest(mafragh$env[,1], nb2listw(mafragh$nb))$obs
sum(tests$obs)
}


sdray/adespatial documentation built on Sept. 12, 2024, 4:36 p.m.