Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: calculating Fishers exact test and recording output for multiple two by two tables at once


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: calculating Fishers exact test and recording output for multiple two by two tables at once
Date   Mon, 17 May 2010 18:12:58 -0500

On May 17, 2010, at 5:22 PM, Michael Walsh wrote:
I would like to calculate a two-sided Fisher's exact test for many studies in one data set and record the test value in a new column (or file). The information from the two-by-two table occupies one row for each study (col 1 = treatment events, col 2 = control events, col 3 = treatment non-events, col 4 = control non-events). Does anyone know of an existing Stata procedure that can accommodate this?


Perhaps the easiest way to do this is with -statsby-. For example, suppose that the two variables that comprise your two-by-two table(s) are called var1 and var2, and suppose that your studies are indexed by a variable called study. In that case, the following will place the p- value and the cell frequencies into individual variables -- one observation per study:

    statsby p=r(p_exact) r1c1=mymat[1,1] r1c2=mymat[1,2] ///
r2c1=mymat[2,1] r2c2=mymat[2,2], by(study): ///
                         tab var1 var2, exact matcell(mymat)


-- Phil

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index