[R-sig-Geo] Fwd: Spatial auto-correlation globally (sphere)

Rolando Valdez rvaldezr at gmail.com
Sun Mar 23 22:46:28 CET 2014


Hi,

I’m not sure what kind of data you have. I work with shapes layers.

Without more information, I expose you what have I done with my data:

> library(rgdal)
> library(sp)
> library(spdep)
> library(lattice)
> library(RANN)
> library(maptools)
Checking rgeos availability: TRUE
> library(rgeos)
> map <-readOGR(".", "zm”) #Reading the shape file.
> neigh=poly2nb(map, queen=FALSE)
> mapaxy=coordinates(map)
> k1=knn2nb(knearneigh(mapaxy, k=1)) #First order matrix weights
> dist=unlist(nbdists(k1, mapaxy))
> summary(dist)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1021    4359    8492   13510   15290  273900 
> wdist20=dnearneigh(mapaxy, d1=0, d2=20000) #Consider relationships within a 20km radio.
> l20=nb2listw(wdist20, style="W", zero.policy=TRUE) #Creating a matrix weights considering 20 km radio.
> summary(l20, zero.policy=TRUE)
Characteristics of weights list object:
Neighbour list object:
Number of regions: 345 
Number of nonzero links: 3296 
Percentage nonzero weights: 2.769166 
Average number of links: 9.553623 
64 regions with no links:
1 2 3 4 25 26 27 28 29 30 31 32 33 34 35 36 37 38 42 44 45 46 47 48 49 56 57 61 62 63 65 66 86 87 88 93 149 150 152 166 167 168 170 172 177 179 228 229 236 237 239 241 242 243 244 284 285 291 298 309 314 315 334 335
Link number distribution:

 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 26 27 28 29 30 31 33 
64 30 21 11 15 20 14 10  9 10 15 12  7  8 10 11 12  9  5 11  2  3  2  1  2  2  4  1  3 
34 35 36 37 38 
 7  3  3  5  3 
30 least connected regions:
23 24 40 41 58 59 60 64 148 151 181 202 212 213 224 225 226 227 230 231 232 233 234 235 294 308 322 325 329 333 with 1 link
3 most connected regions:
262 275 282 with 38 links

Weights style: W 
Weights constants summary:
    n    nn  S0       S1       S2
W 281 78961 281 126.7744 1149.688

After that, you can to do the autocorrelation test (Moran test) with your statistical data:

> test=moran.test(datos$ind_alim, listw=l20, randomisation=TRUE, zero.policy=TRUE)
> test

	Moran's I test under randomisation

data:  datos$ind_alim  
weights: l20  

Moran I statistic standard deviate = 3.762, p-value = 8.428e-05
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance 
      0.135908714      -0.003571429       0.001374638

Other option you have, is to create the neighbor list object with GeoDa.

Hope this example helps,

Regards. 

Inicio del mensaje reenviado:

> De: Alex Mandel <tech_dev at wildintellect.com>
> Asunto: [R-sig-Geo] Spatial auto-correlation globally (sphere)
> Fecha: 23 de marzo de 2014 14:46:19 GMT-6
> Para: Aide R SIG GEO <r-sig-geo at stat.math.ethz.ch>
> Responder a: tech at wildintellect.com
> 
> Has anyone seen a method for creating a neighbor list, for use in
> spatial auto-correlation tests, that treats the earth as a sphere so
> that relationships can go shortest distance. I'm trying to make a
> neighbor list of all countries in the world.
> 
> Yes I realize that the relatedness may not be distance and I might
> weight on some other factor but I need the neighbor list to start.
> 
> Example, US <-> Japan, China or Russia should be a line across the Pacific
> 
> Perhaps I need to develop the neighbor list using some sort of social
> diagramming tool instead.
> 
> Any leads would be appreciated.
> 
> Thanks,
> Alex
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Rolando Valdez



More information about the R-sig-Geo mailing list