Statalist The Stata Listserver


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

st: accumulating t-test results


From   Jeremy Reynolds <[email protected]>
To   [email protected]
Subject   st: accumulating t-test results
Date   Mon, 12 Feb 2007 11:18:03 -0500

I would like to accumulate the results of multiple t-tests into a matrix. Below is a piece of code I have written to accomplish the task, but my suspicion is that there is a better way to collect the results of an r-class command. The creation and manipulation of the matrices, in particular, seems awkward. Can anyone point me in the right direction?

Thanks,

Jeremy

*Create a matrix
matrix input ttestmat = (0)

*Calculate t-tests comparing five variables at three points in time and save the results in the matrix
forvalues i = 1(1)2 {
local j=`i'+1
foreach stub in var1_ var2_ var3_ var4_ var5_ {
quietly: ttest `stub'1==`stub'`j', unpaired
matrix ttestmat= (ttestmat\r(t))
}
}

*Extract the submatrices with results (the first row contains zeros) and re-organize the matrix
matrix ttestmat = ttestmat[2..6,1], ttestmat[7..11,1]
matrix colnames ttestmat = 1v2 1v3
matrix rownames ttestmat = var1_ var2_ var3_ var4_ var5_

*List the results
matrix list ttestmat

--
********************
Dr. Jeremy Reynolds
Assistant Professor
Undergraduate Coordinator
Department of Sociology
117 Baldwin Hall
University of Georgia
Athens, GA 30602-1611
Phone: (706) 583-8072
Web: http://uga.edu/soc/people/faculty/reynolds_jeremy.php
Fax: (706) 542-4320

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