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

From |
Austin Nichols <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0 |

Date |
Sat, 28 Nov 2009 22:22:31 -0500 |

Chris <statachris@gmail.com> : The distance to the nearest village in another region is not the distance to the border; see the conversation with Laura Platchkov (e.g. http://www.stata.com/statalist/archive/2009-09/msg00493.html etc.) on how to compute distance to the nearest vertex on a polygon from a shapefile that gives the boundary between regions. This is still not exactly the distance to the border, but it is closer. Computing actual distance to the border would be a lot more work, but is an interesting programming challenge. And you really need that distance measured accurately in your proposed regression discontinuity design. On Fri, Nov 27, 2009 at 5:49 PM, Stata Chris <statachris@gmail.com> wrote: > Dear Statalisters, > > I would like to construct the assignment variable for a Spatial RDD, > i.e. for each village in either of two regions I would like to know > the distance to the border. > > Now, while I know the x- and y-coordinate of each village in the > sample, I do not know the exact position of each point on the border; > So my idea was to compute for each village in region 1 (0) the > distance to each village in region 0 (1), as > d=sqrt[ (y_1-y_0)^2 + (x_1-x_0)^2 ], > and then take for each the minimum of these as the value for the > assignment variable. Because both regions have quite a few villages, I > will need to compute many such distances, so I think it will probably > be best to do this with a loop. I have a rough idea of what the loop > should do, but I'm not entirely sure how exactly to communicate this > to Stata. > > I am attaching the dataset, and below I provide a rough indication of > what I think are the necessary steps. If one of you was able to help > me put this into a syntax Stata does actually understand, that would > be awesome: > > gen id1 = id if treatment==1 > gen id0 = id if treatment==0 > for each id1 { > for each id0 { > gen dist_id1_id0 = sqrt( (zkx{id1}-zkx{id0})^2 + > (zky{id1}-zky{id0})^2 ) > gen assignmentvar_id1 = min (of all dist_id1_*) > } > } > > And then do the same also the other way round. > > Thank you so much, > Chris > * * 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/

**References**:**st: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0***From:*Stata Chris <statachris@gmail.com>

- Prev by Date:
**st: add total group in -sts graph, by()-** - Next by Date:
**Re: st: Compare ivreg coefficients across models** - Previous by thread:
**Re: st: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0** - Next by thread:
**st: Plotting a Local Polynomial Regression with CIs Accounting for Clustering** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |