Statalist The Stata Listserver


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

Re: st: RE: Fw: RE: formatting and exporting ttest results


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Fw: RE: formatting and exporting ttest results
Date   Thu, 27 Apr 2006 16:36:04 -0400

Juanita-
I decided I ought to test that code I just sent, and sure enough, I
forgot the file handle in the line that puts a star next to a
difference sig. at 5%, viz.
  if r(p)<.05 file write "*"
should be
  if r(p)<.05 file write `out' "*"

But note with !!!!**__extra caution__**!!!! that if you are conducting
multiple hypothesis tests, the p-values on each test are not
correct... typing -findit multiple test- will lead you to some
resources.

Anyway, here's the test code (to see what it does), which should be
easily adaptable to your specific problem--just cut and paste into the
Command window in Stata 9:

clear
set obs 50
forv i=1/25 {
 gen var`i'=uniform()
 la var var`i' "Fake `i'"
 }
gen group1=uniform()>.5
gen group2=1-group1

tempname out
file open `out'  using yourtab.txt, write replace
file write `out' _tab "Group1" _tab "Group2" _tab "Difference"
foreach v of varlist var* {
 qui reg `v' group1 group2, nocons
 qui test group1=group2
 file write `out' _n "`: var la `v''"
 file write `out' _tab "`: di %4.3f _b[group1]'"
 file write `out' _tab "`: di %4.3f _b[group2]'"
 file write `out' _tab "`: di %4.3f _b[group1]-_b[group2]'"
 if r(p)<.05 file write `out' "*"
 file write `out' _n _tab "(`: di %4.3f _se[group1]')"
 file write `out' _tab "(`: di %4.3f _se[group2]')"
 qui reg `v' group1
 file write `out' _tab "(`: di %4.3f _se[group1]')"
}
file close `out'
type yourtab.txt

*
*   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