Raster Local Moran P Value

Posted on

If we look more closely at the Moran I index we see that it can be disaggregated to provide a series of local indices. We start with the standard formulation we provided earlier:

Jan 20, 2021 While you'll be able to use the following method to bypass the login on most Macs, some Mac users will have enabled FileVault and/or a firmware password, making it impossible to hack the Mac without knowing the password(s). Keep in mind that the Mac user will know that someone accessed their computer due to the password change. Keychain has a number of excellent features, but it's not as easy to invoke nor as diverse as 1Password, LastPass, and other third-party password ecosystems. ICloud is a cloud storage and cloud computing service from Apple Inc. Launched on October 12, 2011. As of 2018, the service had an estimated 850 million users, up from 782 million users in 2016. Mac keychain hack free. The Mac will boot into Recovery (we have a separate article about how to boot a Mac in Recovery). When you see the load bar appear you can let go of the keys. It may take a few minutes to load.

Examining the computation of this “global” index provided earlier in Figure 5‑31B, we can see that each row in the computation contributes to the overall sum (Figure 5‑35A), with the covariance component being 16.19 and overall Moran I value 0.03167. Each row item could be standardized by the overall sum of squared deviations and adjusted by the number of cells, n, as shown. The total of these local contributions divided by the total number of joins, ΣΣwij, gives the overall or Global Moran Ivalue. These individual components, or Local Indicators of Spatial Association (LISA), can be mapped and tested for significance to provide an indication of clustering patterns within the study region (Figure 5‑36).

The calculations require some adjustment in order to provide Global Moran Iand LISA values in their commonly used form. The first adjustment is to the weights matrix. It is usual to standardize the row totals in the weights matrix to sum to 1. One advantage of row standardization is that for each row (location) the set of weights corresponds to a form of weighted average of the neighbors that are included, which also enables different models to be readily compared. Row standardization may also provide a computationally more suitable weights matrix. This procedure alters the Global Moran I value when rows have differing totals, which is the typical situation. For the example above the effect is to increase the computed Moran Ito 0.0736. The second adjustment involves using (n‑1) rather than n as the row multiplier, and then the sum is re-adjusted by this factor to produce the Global index value. These changes are illustrated in Figure 5‑35B and Figure 5‑36 and correspond to the computations performed within GeoDa, R and SpaceStat (Anselin, personal communication). ArcGIS offers the option to have no weights matrix standardization, row standardization (dividing rows by row totals) or total weights standardization (dividing all cells by the overall cell total).

The Geary C contiguity index may also be disaggregated to produce a LISA measure, in the same manner as for the Moran I. Another measure, known as the 'G' statistic, due to Getis and Ord (1992, 1995), may also be used in this way. The latter is supported within ArcGIS as both a global index and in disaggregated form for identifying local clustering patterns, which ArcGIS considers this as a form of hot-spot analysis. The ArcGIS implementation of the G statistic facilitates the use of simple fixed Euclidean distance bands (threshold distances) within binary weights (as described below), but also permits the use of the Manhattan metric and a variety of alternative models of contiguity such as: inverse distance; inverse distance squared; so-called Zones of Indifference (a combination of inverse distance and threshold distance); and user-defined spatial weights matrices. Unlike the MoranIand Geary C statistics, the Getis and Ord G statistic identifies the degree to which high or low values cluster together.

Such models exist in a general regression framework (e.g. Generalized additive models), where “local” refers to the values of the predictor values. In a spatial context local refers to location. Lw ## ## Moran I statistic standard deviate = 2.2473, p-value = 0.01231 ## alternative hypothesis. To reconnect these values to the raster. 10.1 Local operations and functions. Local operations and functions are applied to each individual cell and only involve those cells sharing the same location. For example, if we start off with an original raster, then multiply it by 2 then add 1, we get a new raster whose cell values reflect the series of operations performed on the original raster cells. This tool creates a new Output Feature Class with the following attributes for each feature in the Input Feature Class: Local Moran's I index, z-score, p-value, and cluster/outlier type (COType).The field names of these attributes are also derived tool output values. The uncorrected p-value associated with a 95 percent confidence level is 0.05. If your z-score is between -1.96 and +1.96, your uncorrected p-value will be larger than 0.05, and you cannot reject your null hypothesis because the pattern exhibited could very likely be the result of random spatial processes.


Figure 5‑35 Local Moran I computation

Raster Local Moran P Values


A. C*W: Adjustment by multiplication of the weighting matrix, W

B. C*W1: Adjustment by multiplication of the row-adjusted weighting matrix, W1

Figure 5‑36 LISA map, Moran I

The standard global form of the Getis and Ord G statistic is:

whilst the local variant is

The weights matrix, W, is typically defined as a symmetric binary contiguity matrix, with contiguity determined by a (generalized) distance threshold, d. A variant of this latter statistic, which is regarded as of greater use in hot-spot analysis, permits i=j in the expression (so includes i in the summations, with wii=1 rather than 0 in the binary weights contiguity model) and is known as the Gi* statistic rather than Gi. — Note that these local statistics are not meaningful if there are no events or values in the set of cells or zones under examination.

The expected value of G under Complete Spatial Randomness (CSR) is:

where n is the number of points or zones in the study area and W is the sum of the weights, which for binary weights is simply the number of pairs within the distance threshold, d. The equivalent expected value for the local variant is:

where n is the number of points or zones within the threshold distance, d, for point/region i. Closed formulas for the variances have been obtained but are very lengthy. They facilitate the construction of z-scores and hence significance testing of the global and local versions of the G statistics. For the local measure both computed values and z-scores may be useful to map.

The Rookcase add-in provides support for all three LISA measures with variable lag distance and number of lags. Further discussion of these methods is provided in several other sections of this Guide: in Section 5.2, Exploratory Spatial Data Analysis (ESDA); in Section 5.6.5, Spatial filtering models; and in Sections 4.6, Grid Operations and Map Algebra and Chapter 6, Surface and Field Analysis, relating to grid files, since there are parallels between several of the concepts applied.

R tmap spdep sf spData sp
4.0.1 3.2 1.1.5 0.9.6 0.3.8 1.4.4

For a basic theoretical treatise on spatial autocorrelation the reader is encouraged to review the lecture notes. This section is intended to supplement the lecture notes by implementing spatial autocorrelation techniques in the R programming environment.

Sample files for this exercise

Data used in the following exercises can be loaded into your current R session by running the following chunk of code.

The data object consists of a SpatialPolygonsDataFrame vector layer, s1, representing income and education data aggregated at the county level for the state of Maine.

The spdep(Roger S. Bivand 2013) package used in this exercise makes use of sp objects including SpatialPoints* and SpatialPolygons* classes. For more information on converting to/from this format revert back to the Reading and writing spatial data in R Appendix section.


The spatial object s1 has five attributes. The one of interest for this exercise is Income (per capita, in units of dollars).

Let’s map the income distribution using a quantile classification scheme. We’ll make use of the tmap package.

Define neighboring polygons

The first step requires that we define “neighboring” polygons. This could refer to contiguous polygons, polygons within a certain distance band, or it could be non-spatial in nature and defined by social, political or cultural “neighbors”.

Here, we’ll adopt a contiguous neighbor definition where we’ll accept any contiguous polygon that shares at least on vertex (this is the “queen” case and is defined by setting the parameter queen=TRUE). If we required that at least one edge be shared between polygons then we would set queen=FALSE.

For each polygon in our polygon object, nb lists all neighboring polygons. For example, to see the neighbors for the first polygon in the object, type:

Polygon 1 has 4 neighbors. The numbers represent the polygon IDs as stored in the spatial object s1. Polygon 1 is associated with the County attribute name Aroostook:

Its four neighboring polygons are associated with the counties:

Next, we need to assign weights to each neighboring polygon. In our case, each neighboring polygon will be assigned equal weight (style='W'). This is accomplished by assigning the fraction (1/ (# of neighbors)) to each neighboring county then summing the weighted income values. While this is the most intuitive way to summaries the neighbors’ values it has one drawback in that polygons along the edges of the study area will base their lagged values on fewer polygons thus potentially over- or under-estimating the true nature of the spatial autocorrelation in the data. For this example, we’ll stick with the style='W' option for simplicity’s sake but note that other more robust options are available, notably style='B'.

Raster local moran p value list

The zero.policy=TRUE option allows for lists of non-neighbors. This should be used with caution since the user may not be aware of missing neighbors in their dataset however, a zero.policy of FALSE would return an error.

To see the weight of the first polygon’s four neighbors type:

Each neighbor is assigned a quarter of the total weight. This means that when R computes the average neighboring income values, each neighbor’s income will be multiplied by 0.25 before being tallied.

Finally, we’ll compute the average neighbor income value for each polygon. These values are often referred to as spatially lagged values.

The following table shows the average neighboring income values (stored in the Inc.lag object) for each county.

Computing the Moran’s I statistic: the hard way

We can plot lagged income vs. income and fit a linear regression model to the data.

The slope of the regression line is the Moran’s I coefficient.

To assess if the slope is significantly different from zero, we can randomly permute the income values across all counties (i.e. we are not imposing any spatial autocorrelation structure), then fit a regression model to each permuted set of values. The slope values from the regression give us the distribution of Moran’s I values we could expect to get under the null hypothesis that the income values are randomly distributed across the counties. We then compare the observed Moran’s I value to this distribution.

The simulation suggests that our observed Moran’s I value is not consistent with a Moran’s I value one would expect to get if the income values were not spatially autocorrelated. In the next step, we’ll compute a pseudo p-value from this simulation.

Computing a pseudo p-value from an MC simulation

First, we need to find the number of simulated Moran’s I values values greater than our observed Moran’s I value.

To compute the p-value, find the end of the distribution closest to the observed Moran’s I value, then divide that count by the total count. Note that this is a so-called one-sided P-value. See lecture notes for more information.

Raster Local Moran P Value Proposition

In our working example, the p-value suggests that there is a small chance (0.018%) of being wrong in stating that the income values are not clustered at the county level.

Computing the Moran’s I statistic: the easy way

Raster local moran p value list

To get the Moran’s I value, simply use the moran.test function.

Note that the p-value computed from the moran.test function is not computed from an MC simulation but analytically instead. This may not always prove to be the most accurate measure of significance. To test for significance using the MC simulation method instead, use the moran.mc function.

Moran’s I as a function of a distance band

Raster Local Moran P Value

In this section, we will explore spatial autocorrelation as a function of distance bands.

Instead of defining neighbors as contiguous polygons, we will define neighbors based on distances to polygon centers. We therefore need to extract the center of each polygon.

The object coo stores all sixteen pairs of coordinate values.

Next, we will define the search radius to include all neighboring polygon centers within 50 km (or 50,000 meters)

The dnearneigh function takes on three parameters: the coordinate values coo, the radius for the inner radius of the annulus band, and the radius for the outer annulus band. In our example, the inner annulus radius is 0 which implies that all polygon centers up to 50km are considered neighbors.

Note that if we chose to restrict the neighbors to all polygon centers between 50 km and 100 km, for example, then we would define a search annulus (instead of a circle) as dnearneigh(coo, 50000, 100000).

Now that we defined our search circle, we need to identify all neighboring polygons for each polygon in the dataset.

Run the MC simulation.

Plot the results.

Display p-value and other summary statistics.