ccsize                  package:gap                  R Documentation

_P_o_w_e_r _a_n_d _s_a_m_p_l_e _s_i_z_e _f_o_r _c_a_s_e-_c_o_h_o_r_t _d_e_s_i_g_n

_D_e_s_c_r_i_p_t_i_o_n:

     The power of the test is according to 

         Phi(Z_alpha+m^0.5*theta*sqrt(p_1p_2p_D/q+(1-q)p_D))

     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.

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

       n: the total number of subjects in the subcohort

       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

_V_a_l_u_e:

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

_R_e_f_e_r_e_n_c_e_s:

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

_N_o_t_e:

     Programmed for EPIC study

_A_u_t_h_o_r(_s):

     Jing Hua Zhao

_S_e_e _A_l_s_o:

     'pbsize'

_E_x_a_m_p_l_e_s:

     ## Not run: 
     # Table 1 of Cai & Zeng (2004).

     cat("n\tpD\tp1\ttheta\tq\tpower\n")
     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")
              }
           }
        }
     }

     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),"\n")
              }
           }
        }
     }

     # ARIC study

     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),"\n")
     }

     # EPIC study?

     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,"\n")
           }
        }
     }

     # exhaustive search
     nrows <- length(s_pD) * length(s_p1) * length(s_theta) * length(s_q)
     powtable <- matrix(rep(0,nrows * 5),ncol=5,byrow=T)
     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),"\n")
              }
           }
        }
     }
     ## End(Not run)

