# Table 1 of Cai & Zeng (2004).
options(echo=FALSE)
cat("ntpDtp1tthetatqtpower
")
alpha <- 0.05
n <- 1000
for(pD in c(0.10,0.05))
{
for(p1 in c(0.3,0.5))
{
for(theta in c(0.5,1.0))
{
for(q in c(0.1,0.2))
{
power <- ccsize(n,q,pD,p1,alpha,theta)
cat(n,"t",pD,"t",p1,"t",theta,"t",q,"t",signif(power,digits=3),"")
}
}
}
}
n <- 5000
for(pD in c(0.05,0.01))
{
for(p1 in c(0.3,0.5))
{
for(theta in c(0.5,1.0))
{
for(q in c(0.01,0.02))
{
power <- ccsize(n,q,pD,p1,alpha,theta)
cat(n,"t",pD,"t",p1,"t",theta,"t",q,"t",signif(power,digits=3),"")
}
}
}
}
options(echo=TRUE)
# ARIC study
options(echo=FALSE)
n <- 15792
pD <- 0.03
p1 <- 0.25
alpha <- 0.05
theta <- c(1.35,1.40,1.45)
power <- 0.8
s_nb <- c(1463,722,468)
for(i in 1:3)
{
q <- s_nb[i]/n
power <- ccsize(n,q,pD,p1,alpha,log(theta[i]))
ssize <- ccsize(n,q,pD,p1,alpha,log(theta[i]),power)
cat(n,"t",pD,"t",p1,"t",theta[i],"t",q,"t",signif(power,digits=3),"t",ceiling(ssize),"")
}
options(echo=TRUE)
# EPIC study?
options(echo=FALSE)
n <- 25000
alpha <- 0.00000001
power <- 0.8
s_pD <- c(0.3,0.2,0.1,0.05)
s_p1 <- seq(0.1,0.5,by=0.1)
s_theta <- seq(1.2,1.8,by=0.2)
s_q <- seq(0.01,0.5,by=0.01)
# direct calculation
for(pD in s_pD)
{
for(p1 in s_p1)
{
for(theta in s_theta)
{
ssize <- ccsize(n,q,pD,p1,alpha,log(theta),power)
if(ssize>0) cat(n,"t",pD,"t",p1,"t",theta,"t",ssize,"")
}
}
}
# exhaustive search
nrows <- length(s_pD) * length(s_p1) * length(s_theta) * length(s_q)
powtable <- matrix(rep(0,nrows * 5),ncol=5,byrow=TRUE)
ijkl <- 0
for(pD in s_pD)
{
for(p1 in s_p1)
{
for(theta in s_theta)
{
for(q in s_q)
{
ijkl <- ijkl + 1
power <- ccsize(n,q,pD,p1,alpha,log(theta))
powtable[ijkl,] <- c(pD,p1,theta,q*n,power)
cat(n,"t",pD,"t",p1,"t",theta,"t",q*n,"t",signif(power,digits=3),"")
}
}
}
}
options(echo=TRUE)
Run the code above in your browser using DataLab