Re: [R] spdep question - Moran's I

From: Roger Bivand <>
Date: Sat, 19 Apr 2008 21:27:00 +0000 (UTC)

Haenlein.Michael <Michael.Haenlein <at>> writes:

> Dear all,
> I would like to calculate a Moran's I statistic using the moran function in
> the spdep package. The problem
> I'm having deals with how to create the listw object.
> My data stems from the area of social network analysis. I have list of poeple
> and for each pair of them I have a
> measure of their relationship strength. So my dataset looks like:
> Jim; Bob; 0.5
> This measure of relationship strength can be interpreted like a distance
> measure in a spatial model.
> I assume that I need to work with the nb2listw function, but I am lost
> what to do in detail.

If you have a data frame of from, to, weight, and possibly change the column names to suit the sn2listw() function, you might be able to move forward. The from-to strings would need to form a single set of names, where for Moran's I the resulting network may be asymmetric. If you start with a simple example, you can trace things through. If it is the case that sn2listw() wants integers not names, coerce the names (factor levels) to integer.

Perhaps the R-sig-geo list would be more suitable, even if this use is not spatial as such - there is a higher proportion of people there who might be able to help. Probably traceback() and debug(sn2listw) will be your friends in trying to have it do things it was not written for. If you make progress, please say so.

Hope this helps,


> Thanks very much for your help in advance!
> Michael Haenlein
> Assistant Professor of Marketing
> ESCP-EAP European School of Management
> Paris, France mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sat 19 Apr 2008 - 21:32:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 19 Apr 2008 - 22:30:30 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive