Re: [R] Spatial: number of independent components?

2010-06-21 Thread Daniel Malter
as.spam.listw is an unknown function. Is it in a different package? Daniel other attached packages: [1] spdep_0.5-11coda_0.13-5 deldir_0.0-12 maptools_0.7-34 foreign_0.8-38 nlme_3.1-96 MASS_7.3-3 [8] Matrix_0.999375-31 lattice_0.17-26

Re: [R] Spatial: number of independent components?

2010-06-21 Thread nikhil kaza
I have spdep 4.58. Perhaps it is deprecated in the new version. Try looking for sparse matrix representation in the help files for spdep Nikhil On Mon, Jun 21, 2010 at 6:10 AM, Daniel Malter dan...@umd.edu wrote: as.spam.listw is an unknown function. Is it in a different package? Daniel

Re: [R] Spatial: number of independent components?

2010-06-21 Thread Nikhil Kaza
I just updated spdep and I see that as.spam.listw works. Below is sessionInfo Furthermore, it may be straightforward to condense the adjacency matrix *before* converting to graph which may help a little bit. You can profile the code and see which part needs speeding up. library(spdep)

Re: [R] Spatial: number of independent components?

2010-06-21 Thread Daniel Malter
I was missing the spam library. I did some testing with m x m matrices (see below). Computing 'a' is the villain. The computation time for 'a' is exponential in m. For a 100 by 100 matrix, the predicted time is about 20 seconds. Thus, 100,000 runs, would take about 23 days. library(igraph)

[R] Spatial: number of independent components?

2010-06-20 Thread Daniel Malter
Hi all, I am sorry if this is a very basic quesion, but I have no experience with analyzing spatial data and could not find the right function/package quickly. Any hints would be much appreciated. I have a matrix of spatial point patterns like the one below and want to find the number of

Re: [R] Spatial: number of independent components?

2010-06-20 Thread Nikhil Kaza
I am sure this can be written in a much more elegant and faster code. One way I can think of, is to modify cell2nb code and create a new function that creates the neighbour lists of only cells that are not 0. These are best directed to R-sig-Geo list. However, the following might work.

Re: [R] Spatial: number of independent components?

2010-06-20 Thread Daniel Malter
Hi, thanks much. This works in principle. The corrected code is below: a - nb2mat(cell2nb(nrow(x),ncol(x),torus=T), style=B) g - delete.vertices(graph.adjacency(a), which(x!=1)-1) plot(g) clusters(g) the $no argument of the clusters(g) function is the sought after number. However, the function

Re: [R] Spatial: number of independent components?

2010-06-20 Thread nikhil kaza
Instead of nb2mat try as.spam.listw(nb2listw(cell2nb(...))) this will coerce the adjacency matrix into a sparse matrix representation saving lot of memory. Nikhil On Sun, Jun 20, 2010 at 10:27 PM, Daniel Malter dan...@umd.edu wrote: Hi, thanks much. This works in principle. The corrected