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: sppack [was: SSPACK]
From
[email protected]
To
[email protected]
Subject
st: sppack [was: SSPACK]
Date
Thu, 31 Mar 2011 09:42:04 -0500
Ashley Arnio <[email protected]> asked about using the user-written -spmat- command
to create spatial-weighting matrices with weights that are inversely related to
the square distances between the spatial units:
> Is it possible to create an inverse distance squared spatial matrix
> using 'spmat'?
I will illustrate with the ancilliary pollute.dta dataset that comes with the
sppack suite.
First, create an spmat object containing an inverse-distance spatial-weighting
matrix
. use polltue, clear
. spmat idistance dobj longitude latitude, id(id) dfunction(dhaversine)
Now the spatial-weighting matrix, call it W, is contained in the spmat object
dobj. Ashley wishes to square each element of W. To do so, we extract the
matrix from the spmat object into Mata memory and perform the desired
calculation
. spmat getmatrix dobj W id
. mata: W = W:^2
Now we put the transformed matrix back into the spmat object
. spmat putmatrix dobj W id, replace
This technique is illustrated in the working paper 'Creating and managing
spatial-weighting matrices using the spmat command', available at
http://econweb.umd.edu/~prucha/Papers/WP_spmat_2011.pdf.
--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/