Statalist


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

Re: st: display commands generated within foreach-loop


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: display commands generated within foreach-loop
Date   Tue, 20 Nov 2007 11:10:40 -0500

Svend--
I almost agree with you.  To my eyes, the pattern for Stata is to
report lots of identifying information (varnames, etc) for estimates,
and virtually none for tests, so various commands for a two-sided test
of the null of no difference in means across two groups produce
different output based on how Stata thinks of them:

sysuse auto, clear
foreach x of varlist mpg  {
  ttest `x', by(for)
  }
di r(t)^2
foreach x of varlist mpg  {
  hotelling `x', by(for)
  }
foreach x of varlist mpg  {
  reg `x' for
  test foreign
  }
foreach x of varlist mpg  {
  mean `x', over(for)
  test _b[Domestic]=_b[Foreign]
  }

but I can imagine any single user having a different set of desiderata
for default display options, and optionally specified bits as well.
Learning how to use the return codes to -display- what you want is
almost always better than asking Stata to bloat the existing commands
with extra options, IMHO.

In writing the above example, I was struck by the difference between
the VCE and deg. of freedom from -mean- vs. all the other options...
Once you relax the assumption of equal variances, you get quite a
range of p-values:

sysuse auto, clear
qui ttest mpg, by(for) uneq
loc pt=r(p)
qui mean mpg, over(for)
qui test _b[Domestic]=_b[Foreign]
loc pm=r(p)
qui reg mpg for, r
qui test for
loc pr=r(p)
reg mpg if for==1
est sto for
reg mpg if for==0
suest . for
qui test [_LAST_mean]_cons=[for_mean]_cons
loc ps=r(p)
di `pt', `pm', `pr', `ps'


On 11/20/07, Svend Juul <[email protected]> wrote:
> However, I think that Thorstens problem illustrates a
> design problem with the -ttest- output; the names
> of the variables involved ought to be included in the
> output.
*
*   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