Learn R Programming

geostan (version 0.8.1)

moran_plot: Moran scatter plot

Description

Plots a set of values against their spatially lagged values and gives the Moran coefficient as a measure of spatial autocorrelation.

Usage

moran_plot(
  x,
  w,
  xlab = "x (centered)",
  ylab = "Spatial Lag",
  pch = 20,
  col = "darkred",
  size = 2,
  alpha = 1,
  lwd = 0.5,
  na.rm = FALSE
)

Value

Returns a gg plot, a scatter plot with x on the horizontal and its spatially lagged values on the vertical axis (i.e. a Moran scatter plot).

Arguments

x

A numeric vector of length n.

w

An n x n spatial connectivity matrix.

xlab

Label for the x-axis.

ylab

Label for the y-axis.

pch

Symbol type.

col

Symbol color.

size

Symbol size.

alpha

Symbol transparency.

lwd

Width of the regression line.

na.rm

If na.rm = TRUE, any observations of x with NA values will be dropped from x and from w.

Details

For details on the symbol parameters see the documentation for geom_point.

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.

See Also

mc, lisa, aple

Examples

Run this code
data(georgia)
x <- georgia$income
w <- shape2mat(georgia, "W")
moran_plot(x, w)

Run the code above in your browser using DataLab