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

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

From |
"Frederick Guy" <f.guy@bbk.ac.uk> |

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

Subject |
st: RE: RE: RE: AW: Creating index relative to other observations |

Date |
Fri, 30 Apr 2010 12:49:44 +0100 |

Many thanks. Now for a crash-course in MATA... -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 29 April 2010 19:22 To: statalist@hsphsun2.harvard.edu Subject: st: RE: RE: AW: Creating index relative to other observations I'd do this in Mata. Mata has a -for- loop. Nick n.j.cox@durham.ac.uk Frederick Guy Thanks, I guess I was unclear on this aspect of the problem. For each observation, the sum I'm talking about is of measurements made relative to all other observations (or more generally, to some set of other observations) in the sample. Martin Weiss ".. sum up the results of these computations,". Creating sums can mean different things in Stata. It may sound trite, but the easiest is simply to -generate- a sum by adding values with a "+" sign. If you want the total of a variable, look at -egen, total()-. If you want a running sum, take a look at -help sum()-. Frederick Guy I have need to use information from all observations (about 1800 of them) to create a new variable. The variable created is a weighted sum of the inverse of geographical distances between observation i and all j n.e. i. I have longitude and latitude for each observation, and computation of the distance from any i to any j is straightforward. What I don't know is how to get Stata to loop over all observation and sum up the results. For every observation i, I think I need to (a) loop through all j n.e. I, doing computations involving variables x1, x2(i) and x1, x2(j), and then (b) sum up the results of these computations, returning a value which becomes variable x3 for that i. I expect there's a straightforward way to do this. Any suggestions? * * 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: RE: RE: AW: Creating index relative to other observations***From:*Robert Picard <picard@netbox.com>

**References**:**st: Creating index relative to other observations***From:*"Frederick Guy" <f.guy@bbk.ac.uk>

**st: AW: Creating index relative to other observations***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: AW: Creating index relative to other observations***From:*"Frederick Guy" <f.guy@bbk.ac.uk>

**st: RE: RE: AW: Creating index relative to other observations***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: drawnorm for discrete variables** - Next by Date:
**Re: st: How is confidence interval calculated in weighted GLM in Stata?** - Previous by thread:
**st: RE: RE: AW: Creating index relative to other observations** - Next by thread:
**Re: st: RE: RE: RE: AW: Creating index relative to other observations** - Index(es):