mc function

The Moran coefficient (Moran's I)

The Moran coefficient (Moran's I)

The Moran coefficient, a measure of spatial autocorrelation (also known as Global Moran's I)

Source

Chun, Yongwan, and Daniel A. Griffith. Spatial Statistics and Geostatistics: Theory and Applications for Geographic Information Science and Technology. Sage, 2013.

Cliff, Andrew David, and J. Keith Ord. Spatial processes: models & applications. Taylor & Francis, 1981.

mc(x, w, digits = 3, warn = TRUE, na.rm = FALSE)

Arguments

  • x: Numeric vector of input values, length n.
  • w: An n x n spatial connectivity matrix. See shape2mat.
  • digits: Number of digits to round results to.
  • warn: If FALSE, no warning will be printed to inform you when observations with zero neighbors or NA values have been dropped.
  • na.rm: If na.rm = TRUE, observations with NA values will be dropped from both x and w.

Returns

The Moran coefficient, a numeric value.

Details

The formula for the Moran coefficient (MC) is

MC=nKijwij(yiy)(yjy)i(yiy)2 MC = \frac{n}{K}\frac{\sum_i \sum_j w_{ij} (y_i - \overline{y})(y_j - \overline{y})}{\sum_i (y_i - \overline{y})^2}

where nn is the number of observations and KK is the sum of all values in the spatial connectivity matrix WW, i.e., the sum of all row-sums: K=ijwijK = \sum_i \sum_j w_{ij}.

If any observations with no neighbors are found (i.e. any(Matrix::rowSums(w) == 0)) they will be dropped automatically and a message will print stating how many were dropped. (The alternative would be for those observations to have a spatial lage of zero, but zero is not a neutral value.)

Examples

library(sf) data(georgia) w <- shape2mat(georgia, style = "W") x <- georgia$ICE mc(x, w)

See Also

moran_plot , lisa , aple , gr , lg

  • Maintainer: Connor Donegan
  • License: GPL (>= 3)
  • Last published: 2024-12-04