Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: spmat: banded matrix from inverse distances


From   [email protected]
To   [email protected]
Subject   st: spmat: banded matrix from inverse distances
Date   Tue, 05 Jul 2011 07:46:05 -0500

Laszlo Sandor <[email protected]> has some questions about the user-written
-spmat- command:

> I have no fewer than 401,639 observations...  even if I need to keep a band of
> 500, say, I would still keep the size of the banded matrix below 400 MB...
> Using an implementation of a useful sorting from graph theory, I think I could
> code up populating a matrix of the inverse distances outside of Stata.

Mata matrices are stored in double precision, thus with a band of 500 Laszlo
would need 1.5Gb of storage space

  . di (401639*500*8) / 2^30
  1.4962219

Given the size of Laszlo's dataset I doubt the Cuthill-McKee algorithm Laszlo
referred to will reduce the bandwidth to something with which Laszlo can work.

Laszlo also asks whether it is possible to use -spmat import- with a
spatial-weighting matrix in a neighbor list format that contains distance
information.  This can be done by creating a text file in a GeoDa format as
follows

============= begin example.gwt =============
10
1 2 32.8
1 5 15.9
2 4 19.6
3 8 16.5
4 5 18.3
4 6 79.6
5 3 19.4
5 1 11.2
6 4 79.7
6 8 18.3
6 10 19.2
7 4 61.5
7 9 23.7
8 1 3.1
8 2 5.2
9 4 11.6
10 5 10.7
10 7 22.1
============= end example.gwt =============

where '10' in the first line means there are a total of 10 spatial units and the
remaining lines list unit i, unit j, and the distance between them.  To import
this information into an spmat object, Laszlo would code

  . spmat import obj using example.gwt, geoda

At the moment, -spmat import- does not support importing .gwt files in a banded
format.

--Rafal
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index