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

From |
"David Torres" <writeon4truth2@msn.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: Nearest distance (spatial) and shp2dta question |

Date |
Fri, 3 Jul 2009 09:53:23 -0400 |

Quick question before I begin with my own data, however. About the example you give, where in the process of Nichols' example are you beginning? I would like to enter what you have into a .do file to try and follow and see how it works. Again, your assistance is appreciated. I see, too, that you're a student at UMich's sister university, Maryland. Diego ********************************** David Diego Torres, MA(Sociology) PhD Candidate in Sociology 2030D Population Studies Center University of Michigan Institute for Social Research Ann Arbor MI 48106-1248 Tel 734.763.4098 Fax 734.763.1428 torresd@umich.edu ----- Original Message ----- From: "Sergio I Prada" <sprada1@umbc.edu> To: <statalist@hsphsun2.harvard.edu> Sent: Friday, July 03, 2009 9:40 AM Subject: st: Nearest distance (spatial) and shp2dta question > Here another resource (which I got before from the kind people at Stata): > > Havershine is a user written command that calculates the distance using > the Haversine formula, Vincenty formula, and/or the Law-of-Cosines-based > formula. Type the following to install this command: > > net describe vincenty, from(http://fmwww.bc.edu/RePEc/bocode/v) > net install vincenty > > Then, type -help vincenty- to view the help file. By using the hav() > option you > can calculate the distance using the Haversine formula instead of manually > entering the equation. Also, the default is to express the distances in > miles > but you can change this to kilometers with the in km option. > > See one example here > > ********************* > use testdistance, clear > set more off > sort patient > gen id = _n > qui levelsof patient, local(patients) > qui gen shortest_dist = . > qui gen matched_hos = . > foreach p of local patients { > preserve > qui keep if patient==`p' > local pat_long = pat_long[1] > local pat_lat = pat_lat[1] > local obs = id[1] > restore > vincenty `pat_lat' `pat_long' hos_lat hos_long, hav(h) replace > summarize h > qui replace shortest_dist = `r(min)' in `obs' > preserve > keep if round(h,.00001) == round(`r(min)', .00001) > local id = hospital[1] > restore > qui replace matched_hos = `id' in `obs' > > } > drop id > *********************** > > This is calculating the straight distance from the patient to the > hospital. This is not taking into consideratin any physical land barriers, > such as mountains and rivers. > > > -- > Sergio I. Prada, PhD (Candidate) > Department of Public Policy > University of Maryland, Baltimore County > 1000 Hilltop Circle, Baltimore, MD 21250 > Phone: 410-455-6527 > > * > * 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/ > * * 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/

**Follow-Ups**:**Re: st: Re: Nearest distance (spatial) and shp2dta question***From:*Austin Nichols <austinnichols@gmail.com>

**References**:**st: Nearest distance (spatial) and shp2dta question***From:*"Sergio I Prada" <sprada1@umbc.edu>

- Prev by Date:
**st: Re: Nearest distance (spatial) and shp2dta question** - Next by Date:
**RE: st: help: bootstrap with GEE in stata** - Previous by thread:
**st: Re: Nearest distance (spatial) and shp2dta question** - Next by thread:
**Re: st: Re: Nearest distance (spatial) and shp2dta question** - Index(es):

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