Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: "extracting" the p-value from a t-test


From   "Herve STOLOWY" <[email protected]>
To   <[email protected]>
Subject   Re: st: "extracting" the p-value from a t-test
Date   Thu, 24 Nov 2005 17:05:13 +0100

Dear Andrei:

You can also use the following syntax to generate a matrix with all your p-values. This matrix is exported to a txt file (ttest.txt in this example) which can be easily opened with excel. You can also add some more statistics before or after r(p).

capture erase ttest.txt
foreach var of varlist var1 var2 ... varn {
ttest `var', by(groupvar)
matrix ttest = (r(p))
matrix rownames ttest = `var'
matrix colnames ttest = "p-value"
mat2txt, matrix(ttest) saving(ttest) append
}

-mat2txt- is downloadable from ssc.

I hope this helps.

Best regards

Herv� Stolowy







***********************************************************
Professeur/Professor
Coordinateur du D�partement/Head of Department
HEC Paris
D�partement Comptabilit� Contr�le de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
France
Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
[email protected]
http://campus.hec.fr/profs/stolowy/perso/home.htm
>>> [email protected] 11/24/05 1:54 PM >>>
Dear statalisters,
 
I have quite a beginner's question, but due to the
fact that I could not find the (whole) answer I
decided to bother you with this.
 
I have to do lots of  t-tests in a dataset and I am
only interested in the p-value for each two-sided
t-test and not the whole listing that results from
running ttest.
 
My first guess was that it might be some system
variable (like _b or _se in the case of regressions) /
global macro where the p-value is stored, but after
reading the old messages from Statalist I've seen that
it is not so, but on the other hand STATA provides us
with the tools to calculate the p-value. I am
wondering if someone can give me a concrete example
how to do this for a very simple dataset:
 
ttest var1, by(var2)
 
var1   var2
32     1
324    1
523    2
525    2
 
Thank you in advance for your answer!
 
Best regards,
Andrei



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
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/


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