Hi Nick,
I have a small question about the loop that you provided
below. What does the "{col 22}" do? I tried searching for
it but couldn't find any explanation; it seems that you are
providing the width of the column that contains `v'.
If that is the case, then why can't we do the same for the
subsequent columns containing "r(t)" (instead of providing
some blank space with " ")? Is it because this second
column isn't in text format?
Sorry for the bother but a clarification would be helpful.
Thank you,
Nishant
--- Nick Cox <[email protected]> wrote:
> In the case of t tests, a work-around is obtained
> by noting that the results of
>
> regress <response> <binary variable>
>
> are equivalent to
>
> ttest <response>, by(<binary variable>)
>
> so that -outreg- or -estout- (which I think
> you mean here rather than -estimates-) can then be
> used.
>
> Alternatively, a knit-it-yourself approach is
> very simple:
>
> . foreach v of var price-gear {
> 2. qui ttest `v', by(foreign)
> 3. di as txt "`v'" "{col 22}" as res %6.3f r(t) "
> " %5.4f r(p)
> 4. }
> price -0.414 0.6802
> mpg -3.631 0.0005
> rep78 -6.016 0.0000
> headroom 2.609 0.0110
> trunk 3.268 0.0017
> weight 6.246 0.0000
> length 5.890 0.0000
> turn 6.903 0.0000
> displacement 6.597 0.0000
> gear_ratio -8.476 0.0000
>
> The essentials:
>
> 0. Looping over a variable list.
>
> 1. -quietly- executing your statistical command.
>
> 2. Picking up r() stuff (or indeed e() stuff) left in
> memory.
> You can -return list- or -ereturn list- or read the
> manual
> entry.
>
> 3. -display-ing results, with some attention to layout
> and
> formats.
>
> The example above is the third iteration of a real
> example. I
> guessed lucky at r(p) and r(t) and then made changes to
> the layout and formats.
>
> At this point you may want to transfer to your text or
> word processor.
>
> Although I have mixed feelings about the program,
> I note that -makematrix- from SSC gets you there
> too:
>
> . makematrix , from(r(p) r(t)) : ttest price-gear,
> by(foreign)
>
> p t
> price .88738723 .14215113
> mpg .00008982 -4.1688344
> rep78 8.313e-08 -6.0162381
> headroom .00494105 2.9071556
> trunk .00055112 3.6288312
> weight 2.047e-09 6.9268345
> length 2.461e-08 6.3182882
> turn 1.721e-10 7.5259982
> displacement 3.629e-09 6.7875143
> gear_ratio 1.590e-12 -8.6552193
>
> . makematrix results , from(r(p) r(t)) format(%6.3f) :
> ttest price-gear, by(foreign)
>
> results[10,2]
> p t
> price 0.887 0.142
> mpg 0.000 -4.169
> rep78 0.000 -6.016
> headroom 0.005 2.907
> trunk 0.001 3.629
> weight 0.000 6.927
> length 0.000 6.318
> turn 0.000 7.526
> displacement 0.000 6.788
> gear_ratio 0.000 -8.655
>
> In this case, it is fortunate that 3 d.p. work fairly
> well for both p and
> t values. But then with most statistical results 3 d.p.
> often work well,
> although we frequently show many more places as a matter
> of social ritual.
>
> Nick
> [email protected]
>
> Nishant Dass
>
> > Is anyone aware of a command (like "outreg" or
> "estimates")
> > that I could use to tabulate "ttest" or "median" test
> > results?
> >
> > Although I don't think there's one, I just wanted to
> > confirm.
>
> *
> * 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/
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
* 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/