If you have a working function that gives the power for a given sample size
then you can use the uniroot function to find which sample size will give
the desired power (many of the standard power functions use this internally
when computing anything other than power).  You just create a function that
accepts the sample size as the only argument then uses that (along with
your other conditions) to compute the power and subtract from that the
desired power, you pass this function to uniroot and it looks for the
sample size that matches the power.


On Wed, Jan 9, 2013 at 9:21 PM, Kaveh Zakeri <kzak...@ucsd.edu> wrote:

> Hello,
>
> I am trying to get the power function to report the sample size rather
> than the power. My goal is to input a variety of values for theta and then
> for the power function to report the corresponding sample sizes. I haven't
> had much luck trying to create my own function, something along the lines
> of:
>
> f <- function (x) {
>
> power(N=z,a=6,f=6,pi=.5,alpha=.1,t0=10,theta=(1/x),CIFev0=.476,CIFcr0=0))=0.8
> read(z)
> }
>
> In the above example, I am trying to fix the power at 0.80 and solve for
> z, which is the sample size. I would like x to be a random distribution of
> thetas. For instance:
>
> x=rnorm(30,.5,.2)
>
> and then receive the 30 corresponding sample sizes.
>
> Thank you!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to