Statalist


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

Re: st: Teach an old dog new tricks


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Teach an old dog new tricks
Date   Tue, 13 May 2008 10:57:32 -0400

Sergiy Radyakin <[email protected]>:
As for the sparse matrix problem in (A), you can generate a new
variable with all distinct concatenations of rowvar and colvar, then
cycle over the values of that, thereby ignoring the empty cells.

On Tue, May 13, 2008 at 10:18 AM, Sergiy Radyakin
<[email protected]> wrote:
> 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
*
*   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