Bookmark and Share

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

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

st: spmat: banded matrix from inverse distances

From   László Sándor <>
Subject   st: spmat: banded matrix from inverse distances
Date   Fri, 1 Jul 2011 13:59:08 -0400

Hi all,
I am using Stata 11.2 on Unix and mac, and have another question
relating to -sppack-.

I got an answer from Rafal about keeping my spatial correlation matrix
manageable if I only care about adjacency -- as then I can use a
friendship list while importing to spmat, and that matrix can be
banded from the outset, which is a must for me as I have no fewer than
401,639 observations.

However, as my data describes peers with overlapping spells (in prison
cell, for that matter), I would try to keep track of their "inverse
distance" too, which could be say, the number of their days
overlapping. As this would be an integer, thus 2 bytes, even if I need
to keep a band of 500, say, I would still keep the size of the banded
matrix below 400 MB, I hope.

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. My question is, how would that data become useful for
(The algorithm:

Rafal wrote that -spmat use- can only work with files generated by
-spmat- (after an import, say). Does it also imply that there is no
functionality similar to -spmat import ..., nlist- with the bands with
standard -spmat import-, with distances (row-by-row, within the
bands)? The -spmat import- help file seems to imply otherwise first,
though then only mentions the bands for its nlist option further

"By default, spmat import imports data from a space-delimited text
file in which the first line contains the number of columns of the
spatial-weighting matrix and, if applicable, the lower and upper band,
followed by the matrix stored row-by-row with unique place identifiers
recorded in the first column."

"nlist specifies that the text file is in the neighbor-list format.
The first line of the file must contain the total number of places
and, if the matrix is banded, the lower and upper band.  Each
remaining line lists a place ID followed by its neighbors, if any."
Also, I'd be happy to import the inverse distance right away, as those
can be kept integers, while the "distances" in this case would be
needlessly bloated floats.

Thank you very much again,

*   For searches and help try:

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