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

Re: st: sample size


From   "Kazi Mizanur Rahman" <[email protected]>
To   <[email protected]>
Subject   Re: st: sample size
Date   Mon, 10 Jan 2005 08:29:12 +0600

Dear Joseph,

Thank you very much!
Kazi
----- Original Message ----- 
From: "Joseph Coveney" <[email protected]>
To: "Statalist" <[email protected]>
Sent: Thursday, January 06, 2005 4:56 PM
Subject: Re: st: sample size


> Kazi Mizanur Rahman wrote:
>
> The baseline proportion of a an event was 0.9.
> We assume that after providing an intervention in one group for a
particular
> time period we get the proportion as 0.5. We also have a comparison group
> that receives no intervention. After that particular time period the
> proportion becomes 0.8 in the comparison group. How to calculate the
sample
> size with 80% power and alpha .05 ?
>
> --------------------------------------------------------------------------
------
>
> There are undoubtedly some analytical solutions to this power analysis,
but
> have you considered simulation?  See A. H. Feiveson, Power by simulation.
> _The Stata Journal_ 2(2):107-24, 2002. ( www.stata-journal.com/sj2-2.html
for
> an abstract.)  Something analogous to the do-file below might be worth
> considering.  You'd need to take into account any assumptions regarding
> within-subject correlation, if your study design calls for repeated
> measurements.
>
> Joseph Coveney
>
> clear
> set more off
> set seed `=date("2005-01-06", "ymd")'
> *
> program define kazisim, rclass
>     replace res0 = uniform() < 0.9
>     replace res1 = uniform() < (0.8 - `1' * trt * 0.3)
>     logit res1 res0 trt, nolog
>     test trt
>     return scalar p = r(p)
> end
> * Power (under the alternative hypothesis)
> forvalues samplesize = 50(10)100 {
>     display in smcl as result "`samplesize'"
>     clear
>     quietly set obs `samplesize'
>     generate byte trt = _n > _N / 2
>     quietly generate byte res0 = .
>     quietly generate byte res1 = .
>     simulate "kazisim 1" p = r(p), reps(1000)
>     generate byte pos = (p < 0.05)
>     summarize pos
> }
> * Test size (under the null hypothesis)
> forvalues samplesize = 50(10)100 {
>     display in smcl as result "`samplesize'"
>     clear
>     quietly set obs `samplesize'
>     generate byte trt = _n > _N / 2
>     quietly generate byte res0 = .
>     quietly generate byte res1 = .
>     simulate "kazisim 0" p = r(p), reps(1000)
>     generate byte pos = (p < 0.05)
>     summarize pos
> }
> exit
>
> *
> *   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