Statalist


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

Re: st: Teach an old dog new tricks


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: Teach an old dog new tricks
Date   Tue, 13 May 2008 10:18:30 -0400

Thank you all, who responded to my request regarding obtaining a
matrix of means. Besides the answers posted in this thread I have
received a couple of suggestions privately. To summarize and close the
thread, the suggestions can be divided roughly into two groups:

  A. Obtaining all possible levels of the by-variables, then cycling
through these values and computing means for each subgroup. This can
be quite slow, especially in case of "sparse" matrices, where only a
few non-empty cells exist (for a 50x50 matrix -summarize- must be
called 2500 times).

 B. Using other Stata commands which can produce matrix of means as a
by-product. Unfortunately none of them is fast enough either. In
particular, Joseph Coveney suggested using xi to automatically create
all combinations of values and then estimating a univariate
regression. Although this is a very short code, it is perhaps the
slowest, and demands large amounts of memory.

And finally, there is an interesting detail in Austin Nichols' code,
which remained uncommented in the discussion, but may be interesting
to the Stata programmers. I refer to the line:

      loc colc: subinstr local col "." "`=char(183)'", all

where Austin substitutes a dot in the colnames with a character with a
code 183, which is also a dot, but does not cause Stata to complain
"operator invalid".

Thank you all,
   Sergiy Radyakin



On 5/8/08, Joseph Coveney <[email protected]> wrote:
> Sergiy Radyakin wrote:
>
> I am looking for a way to get the matrix of means, which is displayed
> but not saved by, e.g.:
>
> sysuse auto
> table rep78 head, c(mean price)
>
> The (relatively new) svy commands allow this, but they are quite slow
> for the purpose. -table- was in Stata for ages, but it still does not
> save any matrix results.
>
> I am aware of an option replace, which saves the means in the dataset,
> but it destroys the data, - something I am trying to avoid. Adding
> preserve/restore will slow the program down sufficiently enough to
> reject this way of doing it.
>
> Is it possible to obtain a matrix of means from table (or another
> command with a similar functionality) (preferred) ? Or is it possible
> to tell table,replace to keep the existing data and add the computed
> statistics as new variables (good)?
>
> [redacted]
>
> --------------------------------------------------------------------------------
>
> If you're interested in means:
>
> sysuse auto
> xi: regress price i.rep78*i.headroom, noconstant
> matrix list e(b)
>
> Joseph Coveney
>
>
>
> *
> *   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/
>
*
*   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/



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