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

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, and does not wrap around at the sides of the matrix.

Value

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

See Also

indicator_moran, 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 March 21, 2022, 5:08 p.m.