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

From |
Stata Chris <statachris@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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

Date |
Fri, 27 Nov 2009 17:49:22 -0500 |

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

**Attachment:
assignment_variable.dta**

**Follow-Ups**:**Re: st: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0***From:*Austin Nichols <austinnichols@gmail.com>

**Re: st: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0***From:*Roy Wada <roywada@gmail.com>

**st: RE: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**Re: st: Calculating area under a curve** - Next by Date:
**st: RE: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0** - Previous by thread:
**st: Compare ivreg coefficients across models** - Next by thread:
**st: RE: Constructing assignment var for Spatial RDD: For each id in region 1 need shortest distance to an id in region 0** - Index(es):

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