Learn R Programming

gap (version 1.0-14)

ccsize: Power and sample size for case-cohort design

Description

The power of the test is according to $$\Phi\left(Z_\alpha+m^{1/2}\theta\sqrt{\frac{p_1p_2p_D}{q+(1-q)p_D}}\right)$$ where $\alpha$ is the significance level, $\theta$ is the log-hazard ratio for two groups, $p_j$, j=1, 2, are the proportion of the two groups in the population. $m$ is the total number of subjects in the subcohort, $p_D$ is the proportion of the failures in the full cohort, and $q$ is the sampling fraction of the subcohort.

Alternatively, the sample size required for the subcohort is $$m=nBp_D/(n-B(1-p_D))$$ where $B=(Z_{1-\alpha}+Z_\beta)^2/(\theta^2p_1p_2p_D)$, and $n$ is the size of cohort.

Usage

ccsize(n,q,pD,p1,alpha=0.05,theta,power=NULL)

Arguments

n
the total number of subjects in the cohort
q
the sampling fraction of the subcohort
pD
the proportion of the failures in the full cohort
p1
proportions of the two groups (p2=1-p1)
alpha
significant level
theta
log-hazard ratio for two groups
power
if specified, the power for which sample size is calculated

Value

  • The returned value is a value indicating the power or required sample size.

References

Cai J, Zeng D. Sample size/power calculation for case-cohort studies. Biometrics 2004, 60:1015-1024

See Also

pbsize

Examples

Run this code
# 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