Statalist The Stata Listserver

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

st: accumulating t-test results

From   Jeremy Reynolds <>
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?



*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
Fax: (706) 542-4320

* For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index