# st: spatwmat: a further thought on XY coordinates

 From Julia Gamas To statalist@hsphsun2.harvard.edu Subject st: spatwmat: a further thought on XY coordinates Date Fri, 4 Feb 2005 09:07:07 -0500

```Hi again, Simon,
a further thought:
XY coordinates may just be referring to the zone pair:  So in my case if zones 1
and 2 are neighbors then the XY="12" and "21" entries in the table are 1.  If
so it seems a bit "dangerous" to name it this because a geographer will
interpret them as literally the XY coordinates on the globe, making the whole
thing confusing.  But to be sure, probably its better to check with Maurizio
Pisati whom I believe wrote spatreg, spatwmat and spatgsa.  Author addresses
and affiliations appear at the end of the command explanation in the help
window of Stata.  If you manage to find out would you let me know?
Julia

Date: Thu,  3 Feb 2005 14:40:36 -0500
From: Julia Gamas <jgamas@mit.edu>
Subject: st: more on spatial modeling: spatwmat

Dear Simon,

I'm not sure about the coordinates either, but let me explain how I used
"spatwmat", in case it helps you.  Even if different from what you are doing,
I wanted to find spatial correlation.  So I created an "adjacency" matrix with
spatwmat.  In my particular definition of adjacency, the values in the matrix
were 1 if two zones were neighbors and 0 otherwise.  This was first order
adjacency (akin to first order serial correlation in time series).  For some
biological data, second or third order adjacency can be the issue (if you're
interested not in neighbors, but neighbors of neighbors, for example).  I
created the adjacency matrix in a GIS (ArcView) and then imported it into Stata
and created the W matrix using "spatwmat".  My matrix was something like:

zone #:   1    2    3
1  0    1    0
2  1    0    1
3  0    1    0

In this example: zones 1 and 2 are neighbors and zones 2 and 3 are neighbors
but
zones 1 and 3 are not (they aren't adjacent).

I then looked for spatial correlation using "spatgasa" (moran's I and a bunch
of
other types of correlation that Stata tests for).  Then, when I confirmed the
presence of spatial correlation, I ran "spatreg".  You have to determine what
kind of model you are trying to run, and which question you are trying to
limited.  To find out which W you need, you may want to consult Luc Anselin's
books and papers if you haven't done so already, and the author of the Stata
code himself.
I hope this may be of some help.
Julia

> Hi Julia,
>
> Thanks a lot for your information. It is totally new to me that Stata
> has commands for spatial analysis. I looked at the Stata code for
> contracting the weighting matrix, but I am not sure the mechanism behind
> it. Could you explain it to me, if you understand it? I mean, it seems
> to me that the command "spatwmat" uses both y and x to construct the
> weighting matrix, how come? It also occurs to me that each unit has only
> one value, is that so? What exactly are the xcoord(x) and ycoord(y)
> representing?
>
>
> Thanks,
> Simon

*

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```