[R-sig-Geo] RE: [R] adjacency matrix

Christophe Declercq cdeclercq at nordnet.fr
Mon Oct 27 11:43:00 CET 2003



> -----Message d'origine-----
> De : r-sig-geo-bounces at stat.math.ethz.ch
> [mailto:r-sig-geo-bounces at stat.math.ethz.ch]De la part de Roger Bivand
> Envoyé : vendredi 24 octobre 2003 22:19

[...]

> > It's easy to get the adjacency data as WinBUGS want them.
> > Something along the lines of (if 'cantons' is a 'polylist' object):
> >
> > > cantons.nb<-poly2nb(cantons, bb=cantons.bb) # calculate the
> neighbourhood
> > > data<-list(N = length(cantons),
> > + O=lungcanc$o, E=lungcanc$e,
> > + num=sapply(cantons.nb, length),
> > + adj=unlist(cantons.nb),
> > + sumNumNeigh=length(unlist(cantons.nb))
> > +)
>
> Would it be useful for a function doing this to be put into spdep,
> including checking that things "add up"? Should the function write data
> out to a file - probably not, if you are using bugsR as the interface?

Something generic would be useful but not that simple if you want to take
care of:
- the different models we can use (a simple example is the case where we
have an X variable for ecological regression)
- the different ways to connect R and WinBUGS:
  - export all the data from R in a format WinBUGS can read and do all the
work in WinBUGS
  - driving completely the WinBUGS engine from R (the bugsR approach)
  - a semi-interactive way using some of the bugsR functions to write text
files with data and inits, launching WinBUGS script from R (with something
as 'system("C:/\"Program Files\"/WinBUGS14/WinBUGS14 /par script.txt")', do
what you want in WinBUGS: more iterations, MCMC diagnostics... and save what
you want, get back in R when closing WinBUGS, read the saved files you need
in R to map estimates... It's the way I use now.
>
> Would a similar function to output the polygon boundaries in a
> GeoBUGS-friendly format be helpful - should that rather be in maptools?

I don't use GeoBUGS mapping functions at all for the moment (I use
plotpolys()... and poly2nb()...) but, yes, it should be useful. As I
understand it, GeoBUGS read the S maps format: would converting polylist
from/to S maps be useful?

> This is a very fruitful thread - please keep up the flow of
> ideas, because
> the need for data exchange with WinBUGS is clear and if we can get it
> right, should be useful for quite a large (and growing) group of people.
> Could some of us try to do a very rough mini-HOWTO, possibly with the
> author of convert.r (cc to Yue Cui, thread "adjacency matrix" on r-help
> and r-sig-help)?

Good idea! I can try to write a rough HOW-I sketch if you want. I hope
Orlando has eventually been sucessful in his work and so his experience will
be useful.

Christophe
--
Christophe DECLERCQ, MD
Observatoire Régional de la Santé Nord-Pas-de-Calais
13, rue Faidherbe 59046 LILLE Cedex FRANCE
Phone +33 3 20 15 49 24
Fax   +33 3 20 55 92 30
E-mail c.declercq at orsnpdc.org




More information about the R-sig-Geo mailing list