MoransI: Efficiently compute Moran's I statistic

View source: R/RcppExports.R

MoransIR Documentation

Efficiently compute Moran's I statistic

Description

Compute Moran's I for a matrix. A fast implementation of Moran's I for gridded data, with neighbours defined based on a radial distance. Note that when using radius to define the neighbourhood, a radius of one corresponds to the rook's neibhourhood. There is currently no equivalent to queen's neighbourhood.

Usage

MoransI(mat1, r1)

Arguments

mat1

a matrix of values; NA/Inf values must be coded as NA and are ignored

r1

an integer representing the distance (radius), within which nearby cells are considered neighbours in units of rows/columns

Value

a single numeric value for Moran's I

Examples

(TestMat <- matrix(c(1, 0, 1, 0, 1,
                     0, 1, 0, 1, 0,
                     1, 0, 1, 0, 1,
                     0, 1, 0, 1, 0,
                     1, 0, 1, 0, 1),
                   nrow =5))
# the code below should return -1
MoransI(TestMat, r1 = 1)

ICvectorfields documentation built on March 18, 2022, 7:34 p.m.