[R-sig-Geo] Moran's I based on ZIP Code data

Roger Bivand Roger.Bivand at nhh.no
Thu Aug 19 23:53:59 CEST 2010


On Thu, 19 Aug 2010, Michael Haenlein wrote:

> Dear all,
>
> this is probably a very stupid question -- in case it is I apologize in
> advance.
>
> I'm not very familiar with spatial statistics, although I have used the
> spdep package previously (specifically the moran.mc and moran.test
> functions) in a different context.
>
> I have a dataset with roughly 150,000 records where each record corresponds
> to a person. For each record (person) I have a series of continuous
> variables (x1, x2, x3, ...) -- for example how much money the person earns
> or how often s/he buys shampoo - and a ZIP Code where the person is living.
> The ZIP Codes are all five digit and stem from the US (e.g., 10022, 92506,
> 43614).
>
> I'd like to calculate Moran's I for each of my continuous variables in order
> to identify for which measures there is spatial autocorrelation.
>
> Is there a convenient/ automatic way to convert my list of ZIP codes into an
> listw object which I can use as an input for moran.mc or moran.test?

The first thing is to get the locations of the zip codes (about 30,000?) - 
they are published as shapefiles by state (US Census ZCTA), so a polygon 
representation is possible, but you could also look for a point 
representation. Next make a neighbour list (nb) object to the zip code 
entities for which you have observations. Then you could use nb2blocknb() 
in spdep to "block up" observations where more than one belongs to the 
same zip code, which effectively makes all the observations in a zip code 
neighbours, and adds all the observations in neighbouring zip codes too. 
It was written for housing data with only a postcode but no geocoded 
address.

Hope this helps,

Roger

>
> Thanks very much for your help in advance,
>
> Michael
>
>
>
>
> Michael Haenlein
> Associate Professor of Marketing
> ESCP Europe
> Paris, France
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list