[R] Car.proper C[] matrix

Roger Bivand Roger.Bivand at nhh.no
Thu Sep 18 13:28:02 CEST 2008


jgasper <Jason.Gasper <at> noaa.gov> writes:

> 
> 
> I have been using the nb2WB() package for the car.normal function in WinBUGS,
> but it will not create the C[] matrix; it only creates adj[], num[], and
> weights[]. I was planning on using this function to create the C[] matrix
> (by using the num matix) required for the car.proper, but I got slipped up
> on the R coding. My data set is large enough that WinBUGS chokes on the code
> I provided below. 

OK, I understand. Then I think that in the first case on:

http://mathstat.helsinki.fi/openbugs/Manuals/GeoBUGS/Manual.html#Proper

you would use style="W" in nb2listw(my_nb) - row standardisation - and 
rename weights to C, taking M as 1/card(my_nb), and use the glist= 
argument to nb2listw() to set up the second case. The weights[] will then 
be the C[] sparse object indexed by adj[]. Something like this is 
equivalent to example 2:

glist <- vector(mode="list", length=n)
for (i in seq(along=my_nb) glist[[i]] <- sqrt(E[my_nb[[i]]]/E[i])
lw_obj <- nb2listw(my_nb, glist=glist, style="B")

run listw2WB(), and rename weights to C, taking M as 1/E.

Perhaps R-sig-geo would be a more appropriate list - maybe someone there 
has done this already?

Roger Bivand

> 
> Roger Bivand wrote:
> > 
> > Jason Gasper <Jason.Gasper <at> noaa.gov> writes:
> > 
> >> 
> >> Here is the WinBUGS code
> >> 
> > 
> >> 
> >> Uwe Ligges wrote:
> >> > If you want that people help to translate *code*, you have to specify 
> >> > it ...
> >> >
> >> > Uwe Ligges
> > 
> > Please look at the nb2WB() function in the spdep package, I think that
> > you'll 
> > find that it provides what you need.
> > 
> > Roger Bivand
> > 
>



More information about the R-help mailing list