Thank you for your response. However, I don't think the examples on that page relate to my problem. The power function I am using is different than the ones in the pwr package because I am working on the power for survival data with competing risks. I tried to emulate the examples in the link you provided but received an error:
r <- seq(.4,.9,.1)
nr<-length(r)
samsize <- array(numeric(nr),
dim=c(nr))
for (i in 1:r) {
result <- power(N=NULL,a=6,f=6,pi=.5,alpha=.1,t0=10,theta=1/r[i],CIFev0=.40,CIFcr0=0)
samsize[i]<-ceiling(result$N)
}
Error in result$N : $ operator is invalid for atomic vectors
In addition: Warning message:
In 1:r : numerical expression has 6 elements: only the first used
Any help would be appreciated. Thank you.
________________________________
From: Jorge I Velez [jorgeivanvelez@gmail.com]
Sent: Wednesday, January 09, 2013 11:22 PM
To: Kaveh Zakeri
Cc: R-help
Subject: Re: [R] Determining sample size from power function
Dear Kaveh,
Take a look at http://www.statmethods.net/stats/power.html
HTH,
Jorge.-
On Thu, Jan 10, 2013 at 3:21 PM, Kaveh Zakeri <> 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.
[[alternative HTML version deleted]]