Select to view content in your preferred language

Local Moran’s I Calculation Example

3589
5
01-26-2023 11:03 AM
Labels (2)
joshgGIS
Emerging Contributor

I am attempting to manually replicate results obtained from the Cluster and Outlier Analysis tool (ArcGIS Pro v2.9). I have not had any luck, so I’m hoping that someone in the community can help me figure out where I’ve gone wrong. I used the Cluster and Outlier Analysis tool configured as attached. For DeKalb County (highlighted in my attached spreadsheet) the tool gives a Local Moran’s I Index equal to 1.65866.

After running the tool, I tried to replicate the DeKalb County result using the formula shown here: https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-statistics/h-how-cluster-and-outlier...

After running through the math, I keep calculating a different value for Local Moran’s I Index for DeKalb County: 1.700519. Below are my calculations based on the dataset attached. What am I missing?

X bar = 41.509374

x_i (DeKalb County) = 47.009175

n = 75

Dekalb County neighbors and their respective x_j values:

Fulton County: x_j = 48.810092

Clayton County: x_j = 43.978097

Henry County: x_j = 47.661295

Rockdale County: x_j = 45.341663

Gwinnett County: x_j = 46.796238

 

The spatial weight of each of the five neighbors is 0.2, and the other counties in the dataset have a spatial weight of zero.

The above neighbors and weights yield the sum (w_i,j*(x_j-xbar)) = 5.008103.

The sum (x_j-xbar)^2 for all non-DeKalb County features is 1,198.589782, which divided by (n-1) gives an S_i^2 value of 16.197159.

Everything above gives a Local Moran’s I statistic of [(47.009175-41.509374)/16.197159]*5.008103 = 1.700519

Am I mis-understanding or mis-calculating part of the equation for Local Moran’s I? The other features on the map have similar discrepancies between my math and the ArcGIS tool output. I’ve been scratching my head on this one for a few days, so I figured it is time to call in the experts. Thank you!

0 Kudos
5 Replies
AlbertoNieto1
Esri Contributor

Hi Josh, 

Thanks for the question. I think your math looks solid and it would be good for us to take a closer look and replicate the results you're seeing. 

The zipped file has a single .shp file. By any chance would you be able to zip the shapefile once more with all the files it requires? Alternatively you can share it as a feature class in a zipped file geodatabase if that works.  

Alberto

0 Kudos
joshgGIS
Emerging Contributor

Alberto - Thanks for looking into this! Here's the shapefile zipped with all the necessary files.

0 Kudos
OpeyemiKazeem-Jimoh
New Contributor

It would be nice to get the answer to such an important issue. Was the source of the discrepancies ever revealed?

0 Kudos
joshgGIS
Emerging Contributor

I have not received confirmation from Esri on this, but I know what is happening. The attached screenshot shows the calculation that for S_i^2 that is currently listed on the Esri page I linked to in my initial post. The tool is not calculating S_i^2 in the same way. Specifically, the tool is calculating the same S_i^2 for all i.

In my originally posted example, the tool is calculating S_i^2 = 16.6059, whereas the math shown on the page would give S_i^2 of 16.197159. If we swap in my new S_i^2 to the calculation we get a Local Moran’s I statistic of [(47.009175-41.509374)/16.6059]*5.008103 = 1.65866, which matches the tool's output.

I am interested in learning more about why this might be the case.

0 Kudos
EricKrause
Esri Regular Contributor

Hi @joshgGIS,

We apologize for the very long delay in responding, and we really appreciate you pointing this out.  The formula shown in the documentation is not correct; however, the correct formulas are implemented in the tool.

The formula for S_i^2 should not have "j=/=i" in the subscript.  And there's no need for S^2 to have the subscript i at all, since it is just the global variance of the data values and is the same for every feature.

Just to doubly certain, I compared the code and several test cases between the tool and a different implementation in R (spdep module), and all results matched exactly.

Thank you again so much for alerting us to this error and doing this deep digging. This will be corrected in the documentation of the next version of ArcGIS Pro.

- Eric Krause

0 Kudos