Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[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: looping with geodist |

Date |
Fri, 7 May 2010 11:25:32 -0400 |

Frederick Guy <f.guy@bbk.ac.uk> : Except that r(min) should be r(sum), of course. On Fri, May 7, 2010 at 11:23 AM, Austin Nichols <austinnichols@gmail.com> wrote: > conserve memory. Suppose you want the weighted sum of inverse > distances (assuming none are zero); then you could just: > > use type_i, clear > local Ni=_N > merge using type_j > g w=. > qui forv i=1/`Ni' { > g double L=(yj-yi[`i'])*_pi/180 > replace L=(yj-yi[`i']-360)*_pi/180 if L<. & L>_pi > replace L=(yj-yi[`i']+360)*_pi/180 if L<-_pi > local t1 acos(sin(xj*_pi/180)*sin(xi[`i']*_pi/180) > g i=1/(`t1'+cos(xj*_pi/180)*cos(xi[`i']*_pi/180)*cos(L))*6367.44) > su i, meanonly > replace w=r(min) in `i' > drop L i > } > la var w "Sum of Inverse (Approx) Distances" * * 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**:**st: merge-by-observation in stata 10***From:*"Frederick Guy" <f.guy@bbk.ac.uk>

**References**:**st: looping with geodist***From:*"Frederick Guy" <f.guy@bbk.ac.uk>

**Re: st: looping with geodist***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**st: RE: Numerical Integration Stata** - Next by Date:
**Re: st: looping with geodist** - Previous by thread:
**Re: st: looping with geodist** - Next by thread:
**st: merge-by-observation in stata 10** - Index(es):