[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: creating a variable for neighbors
Thanks very much for these helpful ideas, Mr. Southworth and Nick. Is
there anywhere that I can read more about the commands in spatreg and
spautoc? The packages look really helpful, but I am wondering about how
to get the matrix right?
Thanks again for this great help.
Date: Fri, 7 Feb 2003 10:46:57 -0000
From: "Nick Cox" <firstname.lastname@example.org>
Subject: RE: st: RE: creating a variable for neighbors
Caleb Southworth replied to Helen Milner
> :I have a country-year dataset with a variable for the
> number of users of
> :product X for each country year. There are 200 countries
> and 20 years. I
> :would like to create a variable for country I in year t that is the
> :average of its contiguous neighbors' # of users of product X in year
> t. :(Unfortunately, while a country's neighbors is usually
> time invariant,
> :it is not always time-invariant as countries are born and die).
> This is a common GIS task. If you have a map of the
> countries at issue in
> year t, then you can make a spatial contiguity matrix (for example
> using the SpaceStat extension in ArcView for Windows) and then
> compute spatial
> lag (a function of any variable in neighboring units, i.e.
> the average
> value of product X). I compute such weights in SpaceStat
> and merge them
> into my stata datasets for analysis. You could also compute
> them in STATA
> directly if you have coordinates such as country centroids,
> see spatreg
> and related commands.
I don't think contiguous neighbours can be inferred
safely from territory centroids, but in general Caleb
is clearly right: this is a classic GIS task.
As to how you might do it in Stata, apart from
setting up a contiguity matrix, a method I looked
at some years ago was packing the contiguity information
into a string variable. Then you have to loop over
territories, unpack the contiguity information and
do a calculation. The code in -spautoc- on SSC (including various
utilities in the same package) is much of what you want, it seems, as an
option exists to
- -generate- a variable containing a local mean.
* For searches and help try: