[R] New user...tips for spdep?

Roger Bivand Roger.Bivand at nhh.no
Sun Jan 30 14:34:16 CET 2005


On Sat, 29 Jan 2005, Mike Leahy wrote:

> Hello List,
> 
> I'm a very new user to the R system.  I'm only beginning to learn the
> basics, but so far I've been able to do little more than try a few examples,
> and of course begin reading the documentation.
> 
> My primary motivation for exploring R is the availability of tools like the
> 'spdep' package for calculating spatial statistics such as Geary's C and
> Moran's I, which I would like to use in an analysis for my thesis.  However,
> I am not really sure how to get started.  
> 

One place to start looking could be Luc Anselin's useful tutorial:

http://sal.agecon.uiuc.edu/csiss/pdf/rex1.pdf

>  
> 
> As a simple example, if I have a table with columns containing an ID field,
> X & Y coordinates, and an observation value, what steps should I follow to
> pre-process this data in order to use the moran() function?  I've been able
> to duplicate the example in the help documentation (e.g.,
> http://finzi.psych.upenn.edu/R/library/spdep/html/moran.html), but without
> understanding what the commands really do, I'm unable to proceed much
> further.  How might I figure out the data that gets loaded when I run
> 'data(oldcol)' for example?  
> 

In your case, you will need to make a neighbour list object to define what
you understand as the neighbours of your spatial units, for example by
triangulation (tri2nb()), distance bands (dnearneigh()), k-nearest
neighbours (knn2nb()), etc. These are decisions you have to take based on
your knowledge of the phenomena you are analysing. In any case, you would 
use the moran.test() or moran.mc() functions, rather than moran(), which 
just computes the statistic.

In Luc Anselin's example, the neighbour definitions are created in GeoDa, 
which reads shapefiles. In http://spatial.nhh.no/geo304/areal1-04s.pdf, 
they are created for grids and irregular polygons, not for simple points 
like yours. Have a look at the help pages for the point-based functions, 
and see whether any of them suit your purpose. You may have a distance 
range that you know suits your phenomena that you can use, or perhaps the 
triangulation and/or graph-based methods will be more appropriate.

Please feel free to contact me off-list. or to subscribe to the R-sig-geo 
list to follow this up.

(https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo)

Roger Bivand

>  
> 
> Is there anyone that might be able to give me some tips, or point me in the
> right direction?
> 
>  
> 
> Thanks in advance for any suggestions.
> 
>  
> 
> Mike
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

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




More information about the R-help mailing list