[R-sig-Geo] From Sparse Matrix to Listw (capacity problems)

Roger Bivand Roger.Bivand at nhh.no
Tue Oct 24 21:41:26 CEST 2006


On Tue, 24 Oct 2006, Martin Reismann wrote:

> Dear colleagues,
> 
> This message concerns packages spdep and SparseM.
> 
> I have a problem converting a large binary weight matrix (12432 *
> 12432) from matrix.csr class to listw. 
> 
> I tried W.listw <- asListwMatrixCsr(W.csr)
> which gives: error in asListwMatrixCsr(W.csr): row indices out of range

What did traceback() say immediately after the error? Did debug() show the 
error happening before the loop (when you get to the loop, enter c to run 
through)? I think the problem is earlier, in dia, see if any values are 
zero by sum(dia == 0).

Roger

> 
> As a second approach I tried to read elements of the Sparse matrix one
> by one to write an ASCII (GAL) file from W.csr. This failed as well 
> because my method of accessing matrix
>  as.matrix(W.csr[x,y]) 
> is much too slow.
> 
> I am grateful for either:
> - hints how to increase capacity of asListwMatrixCsr
> - hints whether there is a Sparse matrix class and/or single element
> access method which is faster.
> - (or other workarounds).
> 
> Best wishes,
> Martin Reismann
> 
> ---
> Mag. Martin Reismann
> c/o
> Institut fuer Wirtschaftsgeographie und Geoinformatik
> Wirtschaftsuniversitaet Wien
> Nordbergstrasse 15, 4. Stock, Kern A
> A-1090 Wien
> 
> EMail: Martin.Reismann at wu-wien.ac.at
> Tel +43-(0)-1-31336-5720
> Fax +43-(0)-1-31336-703
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

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




More information about the R-sig-Geo mailing list