Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nikolaos Pandis <npandis@yahoo.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: power calculation graphs |

Date |
Fri, 20 Aug 2010 08:35:02 -0700 (PDT) |

Many thanks David. This was really helpful. Nick --- On Fri, 8/20/10, Airey, David C <david.airey@Vanderbilt.Edu> wrote: > From: Airey, David C <david.airey@Vanderbilt.Edu> > Subject: Re: st: power calculation graphs > To: "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> > Date: Friday, August 20, 2010, 5:48 PM > . > > While you can use -postfile-, you can also work directly > with a Stata data file. Here's a simple example of making a > power graph: > > > clear > > set obs 7 // make a data set of 7 observations > > generate size = . // prepare variable for data > > generate power = . // prepare variable for data > > local i 1 // i is used to identify data rows > > foreach power of numlist 0.50(0.10)0.90 0.99 { // set up a > loop > > sampsi 9 13, sd1(2) sd2(4) > power(`power') alpha(0.05) > > replace size = r(N_1) in `i' // add size > result to data set > > replace power = `power'*100 in `i' // > add power result to data set > > local i = `i' + 1 // increment to the > next row > > } // end the loop > > graph twoway connected power size, /// > xlabel(0(5)25) mc(red) lc(red) // make a > graph > > graph export plot1.pdf, replace // Apple OS X only > > > Also, there are power(ful) articles in the Stata Journal: > > Generalized power calculations for generalized linear > models and more > R. Newson. 2004. > Stata Journal Volume 4 Number 4. > > Power by simulation > A. H. Feiveson. 2002. > Stata Journal Volume 2 Number 2. > > > On Fri, Aug 20, 2010 at 8:54 AM, Nikolaos Pandis <npandis@yahoo.com> > wrote: > > Hi to all. > > > > I was wondering if someone would be able to help me > draw the following sample calculation graphs with Stata: > > > > 1. Two arm parallel trial, outcome binary. > > > > A power (y-axis) sample size (x-axis) calculation > graph for various failure proportions between trial arms. > For example, p1=0.80 and p2=0.85, or p1=0.80 p=0.90 or > p1=0.80 p=0.95 > > > > > > 2. Two arm parallel trial, outcome continuous. > > > > A power (y-axis) sample (x-axis) calculation graph for > various failure proportions between trial arms. For example, > m1= 100 and m2= 120 with equal sd1=sd2=10. It would be great > if I could vary m1, m2, sd (always sd1=sd2) > > > > You can do both of these using the -sampsi- command and > could have > found this yourself by typing -search sample size- into > Stata. > > If you want to do the analysis for a range of values then > you should > consider putting each call within a series of nested > -forval- loops > and write the results to a file using -postfile- which you > can then > read into Stata and draw the graphs you want. > > I'll leave the actual coding of this as an exercise for you > to work on ;-) > > Neil > > > > * > * 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/

**References**:**Re: st: power calculation graphs***From:*"Airey, David C" <david.airey@Vanderbilt.Edu>

- Prev by Date:
**st: -insheet- doesn't respect quotes** - Next by Date:
**Re: st: -insheet- doesn't respect quotes** - Previous by thread:
**Re: st: power calculation graphs** - Next by thread:
**st: F-test Stata reg..., robust** - Index(es):