moranplotmap: Moran scatterplot and map

View source: R/moranplotmap.R

moranplotmapR Documentation

Moran scatterplot and map

Description

The function moranplotmap() draws a moran plot, used to detect spatial autocorrelation in the variable var. On the x-axis, is represented x-\bar{x} and on the y-axis W(x-\bar{x}), where W is the spatial weight matrix. It also calcultes Moran's I statistic (see nonnormoran) and give a p-value associated to the autocorrelation test (gaussian version and permutation version).

Usage

moranplotmap(sf.obj, name.var, listw.obj, flower = FALSE, locmoran = FALSE, 
 names.arg = c("H.-H.", "L.-H.", "L.-L.", "H.-L."), 
 criteria = NULL, carte = NULL, identify = NULL, cex.lab = 0.8, pch = 16, 
 col = "lightblue3", xlab = "", ylab = "", axes = FALSE, lablong = "", lablat = "")

Arguments

sf.obj

object of class sf

name.var

a character; attribute name or column number in attribute table

listw.obj

object of class listw

flower

if TRUE, link neighbouring sites

locmoran

if TRUE, print local Moran's I statistic on the Moran plot

names.arg

names of the quadrant of the Moran plot

criteria

a vector of boolean of size the number of spatial units, which permit to represent preselected sites with a cross, using the tcltk window

carte

matrix with 2 columns for drawing spatial polygonal contours : x and y coordinates of the vertices of the polygon

identify

if not NULL, the name of the variable for identifying observations on the map

cex.lab

character size of label

pch

16 by default, symbol for selected points

col

"lightblue3" by default, color of bars on the histogram

xlab

a title for the graphic x-axis

ylab

a title for the graphic y-axis

axes

a boolean with TRUE for drawing axes on the map

lablong

name of the x-axis that will be printed on the map

lablat

name of the y-axis that will be printed on the map

Details

For the permutation test, for each drawing the values of the variable var are randomly assigned to the sites. We then calculate Moran'I statistic associated to each drawing and we give the frequency of drawings when Moran'I statistic is lower or equal to the observed Moran'I statistic. Moreover, the function gives the opportunity to link neighbouring sites and gives Local Moran's I statistic. For a site i:

I_i=(x_i-\bar{x})\sum_{j}W_{ij}(x_j-\bar{x})

with j not equal to i.

Value

In the case where user click on save results button, a list is created as a global variable in last.select object. \$obs, a vector of integer, corresponds to the number of spatial units selected just before leaving the Tk window, \$MORAN, a numeric, corresponds to the value of the Moran'I statistic.

Note

In the case of the spatial weigth matrix is not normalized, the Moran'I statistic is not equal to \beta used in regression line for model W(X-\bar{X})=\beta(X-\bar{X})+u. That is why the regression line is only drawn in the case of W normalized.

Author(s)

Aragon Y., Thomas-Agnan C., Ruiz-Gazen A., Laurent T., Robidou L.

References

Thibault Laurent, Anne Ruiz-Gazen, Christine Thomas-Agnan (2012), GeoXp: An R Package for Exploratory Spatial Data Analysis. Journal of Statistical Software, 47(2), 1-23.

Roger S.Bivand, Edzer J.Pebesma, Virgilio Gomez-Rubio (2009), Applied Spatial Data Analysis with R, Springer.

Jim Lesage, “Spatial Econometrics Toolbox”, http://www.spatial-econometrics.com/

See Also

neighbourmap,makeneighborsw,normw,nonormmoran

Examples

##
require(sf)
# data baltimore
if (require(spData, quietly = TRUE)) {
 data(baltimore, package = "spData")
}

# SpatialPoints
baltimore_sf <- st_as_sf(baltimore, coords = c("X", "Y"))
# Spatial Weight Matrix
W.nb <- spdep::knn2nb(spdep::knearneigh(baltimore_sf, k = 4))
# We choose a row standardized spatial weight matrix :
W.listw <- spdep::nb2listw(W.nb, style = "W")

# moranplotmap with some options
moranplotmap(baltimore_sf, "PRICE", W.listw, 
  flower = TRUE, locmoran = TRUE, criteria = (baltimore.spdf$AC == 1),
  identify = "STATION")

# comparison with the moran.test function
spdep::moran.test(baltimore_sf$PRICE, W.listw)
 
## Not run:  
# data columbus
require("sf")
columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1])
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])

# use of moranplotmap with spatial weight matrix col.gal.nb :
# 1. row-standardized
moranplotmap(columbus, "HOVAL", nb2listw(col.gal.nb, style = "W"))

# 2. basic binary
moranplotmap(columbus,"HOVAL",nb2listw(col.gal.nb,style="B"))

# 3. globally standardized
moranplotmap(columbus, "HOVAL", nb2listw(col.gal.nb, style="C"))

## End(Not run)

tibo31/GeoXp documentation built on April 8, 2023, 7:50 a.m.