[R-sig-Geo] newbie: Moran's I

Roger Bivand Roger.Bivand at nhh.no
Fri Nov 3 14:44:22 CET 2006


On Fri, 3 Nov 2006, Jeffrey Stratford wrote:

> Hi.
> 
> Does anyone have an example of estimating Moran's I from a file with
> point (not polygon) data?  I'm getting close(r) but I still have a few
> problems.
> 
> Here's my code so far:
> 
> library(spdep)
> ctpoints <- read.csv("c:\\Georgia\\xy.csv", header=TRUE)
> # only two columns containing the long-lat data 
> str(ctpoints)
> plot(ctpoints)
> neigh <- tri2nb(ctpoints)
> plot (neigh, ctpoints)
> nblist <- nb2listw(neigh, glist=NULL, style="W", zero.policy=FALSE)
> ????? <- spNamedVec("?????", ctpoints)
> gamoran <- moran(?????, nblist, n, S0, zero.policy=FALSE, NAOK=FALSE)   
>  
> 
> I'm not sure what goes where I have "?????".  And yup, I did a
> help(spNamedVec) but I'm not sure how to translate that material to my
> case.  
> 

The spNamedVec() mechanism was introduced four years ago as an existential
scream (think Munch) after seeing (published) results for data and a
neighbour list sorted in different orders. The idea was to name the data
vector, and, if required, compare those names with the region.id attribute
of the neighbours list.

But I think my concern that users might re-order the data wrt.  the
neighbour list (or vice-versa) by accident was rather extreme, so I guess
I'll remove the heavy-handed use of spNamedVec() from the examples. Your
????? should simply be the variable of interest (which isn't in ctpoints,
which only have two columns), which should be of length equal to the
number of rows in dtpoints. For now runif(nrow(ctpoints)) would give you a
dry run, and should not be autocorrelated.

Roger


> Eventually, I would like to run a number of Poisson or negative binomial
> regressions linking avian species richness to landscape variables around
> the same points where I surveyed birds. See
> http://web6.duc.auburn.edu/~stratja/georgia.pdf (map showing points on a
> LANDSAT map) to get an idea of the proximity and location of points.
> Since I will eventually incorporate spatial effects into my regressions
> should I change the file to one that contains the coordinates, the bird
> data, and the landscape data? 
> 
> Many thanks (again),
> 
> Jeff
> 
> ****************************************
> Jeffrey A. Stratford, Ph.D.
> Postdoctoral Associate
> 331 Funchess Hall
> Department of Biological Sciences
> Auburn University
> Auburn, AL 36849
> 334-329-9198
> FAX 334-844-9234
> http://www.auburn.edu/~stratja
> 
> _______________________________________________
> 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