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
"Kieran McCaul" <[email protected]>
To
<[email protected]>
Subject
RE: st: calculating Fishers exact test and recording output for multiple two by two tables at once
Date
Tue, 18 May 2010 07:16:59 +0800
...
or this:
clear
input id a b c d
1 5 9 3 5
2 1 5 3 7
3 2 9 4 3
end
gen p=.
forvalues i = 1/`=_N' {
tabi `=a[`i']' `=b[`i']' \ `=c[`i']' `=d[`i']' , exact
replace p = `r(p_exact)' in `i'
}
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael
Norman Mitchell
Sent: Tuesday, 18 May 2010 6:46 AM
To: [email protected]
Subject: Re: st: calculating Fishers exact test and recording output for
multiple two by two tables at once
Dear Mike
I wonder if this example below will help. It has four columns named a
b c and d, corresponding to the four frequencies you describe. I rename
them to v1 v2 v3 v4, and reshape them to a long format. I then create
the variable -event- and -trt- to correspond to event and treatment, and
then use -tab- to create the fishers exact tests, and add -bysort id- to
do this separately for each study.
I hope this helps.
Michael N. Mitchell
See the Stata tidbit of the week at...
http://www.MichaelNormanMitchell.com
-- snip ---
clear
input id a b c d
1 5 9 3 5
2 1 5 3 7
3 2 9 4 3
end
rename a v1
rename b v2
rename c v3
rename d v4
reshape long v, i(id) j(condition)
generate event = 1 if inlist(condition,1,2)
replace event = 0 if inlist(condition,3,4)
generate trt = 1 if inlist(condition,1,3)
replace trt = 0 if inlist(condition,2,4)
bysort id: tab event trt [fw=v], exact
-- snip ---
On 2010-05-17 3.22 PM, Michael Walsh wrote:
> Hello all,
>
> 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?
>
> Thanks for considering,
> Mike
>
> *
> * 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/
>
*
* 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/
*
* 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/