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 |
Nick Cox <njcoxstata@gmail.com> |

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

Subject |
Re: st: Collecting Statistics of Averages of Variables |

Date |
Fri, 28 Sep 2012 19:24:15 +0100 |

Check out -statsby-. Nick On 28 Sep 2012, at 18:55, robert hartman <rohartman@gmail.com> wrote:

Hi Listers, I'm struggling with a couple of programming challenges. I will start with this one. Any input on efficient ways to code this would be most appreciated. I want to take mean (or could be other "egen"/"collapse" type summary statistic) form all possible combinations (of subsets of various sizes) from a set of variables. For example, if I have v1, v2, v3, and v4, I would want the mean of each: v1v2, v1v3, v1v4, v1v2v3, v1v2v4, v1v3v4...v3v2...v3v2v4, etc. By v1v2v3, I mean gen v1v2v3=(v1+v2+v3)/3; (assuming the summary statistic of interest is the mean) by v1v2v3v4, I mean v1v2v3v4=,I mean gen v1v2v3v4=(v1+v2+v3+v4)/4. etc. I don't need to actually create permanent variables, simply 1. create a temporary "combination variable" (e.g., v1v2v4 = rowmean(v1 v2 v4)) for each possible combination,2. collect summary statistics of interest from "combinationvariables."3. spit out a file that conveys this information intelligibly For example, I may want to write out a file that gives (a) the name of the combination (e.g., v1v2v4--the column representing the rowmean of those three variables) and (b) the mean and standard deviation of that v1v2v4 variable. In my particular case, I have about a 70 variable space from which to create all these subset combinations. Any helpful starting points or coding ideas would be helpful. Thanks, Rob Hartman * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Collecting Statistics of Averages of Variables***From:*robert hartman <rohartman@gmail.com>

**References**:**st: Collecting Statistics of Averages of Variables***From:*robert hartman <rohartman@gmail.com>

- Prev by Date:
**st: dynamic graphs** - Next by Date:
**st: comparing 25th percentile survival time between two race groups** - Previous by thread:
**st: Collecting Statistics of Averages of Variables** - Next by thread:
**Re: st: Collecting Statistics of Averages of Variables** - Index(es):