Skip to content
Prev 22428 / 29559 Next

Local Moran p-values in Geoda, Python, and R

Here's the R LISA map:
http://willonrails.com/images/Lisa_map_R.png

And here's the Geoda version:
http://willonrails.com/images/Lisa_map_geoda.png

I'm using Geoda 1.6.6. Since we were getting inconsistent answers
between R and Geoda, the professor ran the analysis in Python to
get a third opinion. I don't have the Python version of the map
on me, but it's very similar to Geoda's.

I was able to export Geoda's local I and p-values. I put up a zip file
with all the data, R script, the maps, and the spatial weights files
for Geoda:
willonrails.com/images/lisa_spdep.zip

The local Moran's I in R and Geoda are very similar -- on average they
only differ by 0.000290044.

The p-values, on average, differ by 0.1808931.

In both I used 10 nearest neighbors for the weights. I did create the
weights separately in R and Geoda. The Geoda weights are in the zip
file. I'm new to coordinate projections, but here's the relevant part
of the R script:

------------------------------------------------
# nearest neighbors (nnb)
coords <- coordinates(nat)
IDs <- row.names(as(nat, "data.frame"))
nat_10nnb <- knn2nb(knearneigh(coords, k=10), row.names=IDs)
------------------------------------------------

'nat' is an object of class SpatialPolygonsDataFrame, so if I
understand correctly I don't need to set the 'longlat' argument in
knearneigh. I also plotted a random selection of the counties in R,
along with their neighboring counties from the weights matrix, and
everything appeared to be working correctly.

I also tried using Geoda's weights in R. Surprisingly, this map is
even sparser (higher p-values) than the first map I made in R. I'm
tempted to think I mixed up the data, but the map looks correct
when I plot all counties regardless of p-value.








----------------------------------------