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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
st: RE: Sum product of each element with each other element except itself? |

Date |
Sun, 16 Aug 2009 12:26:03 +0200 |

<> This FAQ may be helpful: http://www.stata.com/support/faqs/data/members.html Apart from that, give an excerpt of your data, and show exactly what you want to happen to it... HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Stata Chris Sent: Sonntag, 16. August 2009 01:19 To: statalist@hsphsun2.harvard.edu Subject: st: Sum product of each element with each other element except itself? Hi, I would like to compute the following in Stata: Sum over all n of: Sum over all m unequal n of: (D_nt - p)*(D_mt - p), where m, n, t are subindices. If it was with only a single sum and without the unequal condition, I would just have used sth like this: bysort m n t: gen factor1 = (D_nt - p) bysort m n t: gen factor2 = (D_mt - p) bysort t: egen result = sum(factor1*factor2) But I'm not sure how to get the product for each element n with each other element from the same set except itself. Should I do this with a loop or sth? Many thanks, 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/ * * 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: RE: RE: Sum product of each element with each other element except itself?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: Sum product of each element with each other element except itself?***From:*Stata Chris <statachris@gmail.com>

- Prev by Date:
**Re: st: RE: Differential effect; regression coefficients** - Next by Date:
**Re: st: equivalence limit** - Previous by thread:
**st: Sum product of each element with each other element except itself?** - Next by thread:
**st: RE: RE: Sum product of each element with each other element except itself?** - Index(es):

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