> At 03:30 PM 12/28/2006, Claude Francoeur wrote:
> > I am comparing means for several variables (varname2 to varname10)
> > Is there a command or do file to do all these comparisons at once
> > and perhaps generate a summary of the results in a table?
--- Fred Wolfe <[email protected]> wrote:
> You have to use the foreach command
-foreach- is indeed the answer to the question, but there is an
additional issue with performing multiple tests. The idea behind
calling something statistically significan at (for instance) the 5%
level is that you accept a probability of 5%, or one in every 20 tests,
that we reject the null hypothesis when we actually should not. If we
perform many tests, than we know that some of the significant results
are actually (type I) errors and we need to correct for that. Within
Stata this can be done with the -_mtest- command, see example 1 below.
If you think that all that is too much trouble for just a little
exploratory look inside your data than you are probably using the wrong
tool: test are for testing specific hypotheses, graphs are for looking
at your data. So for exploratory data analysis I would strongly suggest
you would not use the ttest but instead use graphs, for instance the
-dotplots- in example 2.
*------------- begin example 1 ------------------
set more off
sysuse auto, clear
matrix result = J(10,2,0)
local i = 1
tempname t p
foreach var of varlist price-gear_ratio {
qui ttest `var', by(foreign)
scalar `t' = r(t)
scalar `p' = 2*ttail(r(df_t),abs(r(t)))
matrix result[`i++',1] = `t',`p'
}
matrix list result
_mtest adjust result, mtest(bonferroni) pindex(2) replace
matrix list r(result)
*------------ end example 1 ----------------
*----------- begin example 2 ---------------
sysuse auto, clear
foreach var of varlist price-gear_ratio {
dotplot `var', over(foreign) name(`var')
local combine "`combine' `var'"
}
graph combine `combine'
*------------- end example 2 ----------------
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
___________________________________________________________
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy and free. http://uk.docs.yahoo.com/trueswitch2.html
*
* 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/