Learn R Programming

spatialwarnings (version 3.1.0)

raw_moran: Spatial correlation at lag 1

Description

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

Usage

raw_moran(mat)

Value

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

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.

See Also

generic_sews

Examples

Run this code

# 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)

Run the code above in your browser using DataLab