raw_moran: Spatial correlation at lag 1

View source: R/RcppExports.R

raw_moranR Documentation

Spatial correlation at lag 1

Description

This function computes the Moran's I index of spatial correlation at lag 1.

Usage

raw_moran(mat)

Arguments

mat

A matrix containing logical, numeric or integer values

Details

This function returns the spatial correlation as measured by the Moran's I index. If the variance of the matrix is zero, then NaN is returned. This function assumes a 4-way neighborhood (a.k.a. von-Neumann neighborhood), and does not wrap around at the sides of the matrix.

Value

The Moran's I numeric value as a numeric number.

See Also

generic_sews

Examples


# Spatial correlation of white noise is close to zero
rmat <- matrix(runif(1000) > .5, ncol = 100)
raw_moran(rmat) 

# Spatial correlation of a half-ones / half-zeros matrix is close to one. 
# This would produce close but inaccurate results in version <3.0.2
m <- cbind(matrix(1, nrow = 100, ncol = 50), 
           matrix(0, nrow = 100, ncol = 50))

raw_moran(m)


spatialwarnings documentation built on Sept. 11, 2024, 8:55 p.m.