[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: RE: matrix of variable averages |

Date |
Tue, 9 Dec 2003 13:16:43 -0000 |

Theuer Stefan > To this solution i have 2 questions: > 1) What is the meaning of the transpose mark, in my opinion > the syntax should also run without this mark. The original questioner clearly specified that he wanted a column vector. In this case, -tabstat- saves results as a row vector. For that desired outcome, you need to transpose. If you are happy with a row vector, the transpose is indeed unnecessary. > 2) if i like getting not alone the results of the total > mean but also the differences between the mean of all items > and grouped items i used the following ado file. My > question is, is there a way to use the labels of the > by-variable for the matrix list command at the bottom? > > program define compmean > version 8.0 > syntax varlist [if] [in], by(varname) > > marksample touse > quietly levels `by' if `touse', local(K) > > > > * total > > di as text _newline(2) "{hline 104}"_newline "total means"_newline > tabstat `varlist' if `touse', stats(mean) format(%9.3f) > save casewise > matrix total = r(StatTot) > di _newline "{hline 104}" _newline(2) > > * groupwise > > di _newline "{hline 104}" _newline "means of the groups" _newline > tabstat `varlist' if `touse', stats(mean) by(`by') > format(%9.3f) save casewise nototal miss > di _newline "{hline 104}" _newline(2) > > * matixes of the means of the groups and differencies of the means > > foreach num of numlist 1/`K'{ > matrix cl`num' = r(Stat`num') > matrix cl`num't = (cl`num' - total)*100 > > } > > * display > di _newline(2) "{hline 104}" _newline "differences of the > means" _newline > > foreach num of numlist 1/`K' { > di _continue "Cluster `num' " > matrix list cl`num't, noheader format(%9.1f) noblank nonames > } > > di "{hline 104}" > > end > exit This program is still fairly buggy e.g. it seems to assume categorical variables are numeric and labelled 1 up. I'd approach this from the point of view of creating temporary variables which are deviations from the mean, and then calling up -tabstat-; that is, do more upstream of -tabstat- and much less downstream. Nick Cox > > . tabstat experience education children, s(mean) save > > . matrix mean = r(StatTot)' > > . matrix li mean > > > > Note the transpose mark. Mohamad Khalid Dimaporo > > > Im a beginner with stata and cant find a simple method to > > > create a (n x 1) > > > matrix of my variable averages. For example, what command > > > do I type to get a > > > 3 x 1 matrix of the averages of experience education children. Nick n.j.cox@durham.ac.uk * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: RE: matrix of variable averages***From:*Theuer Stefan <Stefan.Theuer@iab.de>

- Prev by Date:
**st: Sargan test in xtivreg, re** - Next by Date:
**st: tobit and SUR- can it be estimated in Stata?** - Previous by thread:
**st: RE: matrix of variable averages** - Next by thread:
**st: Option checking of filename** - Index(es):

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