Wednesday, August 14, 2013

R Function for Simulating the Sample Size, Type I error and Power in Adaptive Group Sequential Design

Description


The R function SAP() returns the planning sample size, simulated sample size, simulated standard error, simulated arm1/arm2 event rate and standard error, simulated type I error and statistical power  for four methods (see references) with binary outcomes.

Usage


SAP(r, type1, type2, interim, tpi1, delta,p)
tra.size(type1, type2, pi1, pi2,delta) #return Chow's sample size
Gould.size(type1, type2, opi, delta) #return Gould Sample size
Shih.size(n,r, type1,type2,tpi1,tpi2,p,interim
##return Shih's sample size, n is the sample size from either Gould or Chow.


Arguments

r                   number of replicates in simulation, such as 10000
type1           designed type1 error, such as 0.05
type2           designed type2 error, such as 0.2 (power=0.8)
interim        the proportion of total information by which interim analysis is planned, such as 0.3
tpi1             designed arm 1 event rate, such as 0.3
delta            minimum clinical effect size, such as 0.2
p                 the stratification factor for Shih's method, say 0.3 suggested by the paper.

Examples


To run the functions, you either to copy all the R codes from here or copy the following scripts to the R Gui window:

Download the function code on Mac:

download.file("https://raw.github.com/devilszhang/blog/master/SAP.r", destfile="./SAP.r", method="curl")


Download the function code on Windows:


download.file("https://raw.github.com/devilszhang/blog/master/SAP.r", destfile="./SAP.r")

Source the code:

source("./SAP.r")

Suppose you're planning a trial with the desired values in Arguments:

SAP(r=10000, type1=0.05, type2=0.2, interim=0.3, tpi1=0.3, delta=0.2, p=0.3)



References


  1. Chow S.C., et al. Sample Size Calculations in Clinical Research, Marcel Dekker Inc.: New York, 2003.
  2. Gould A. L., et al. Statistics in Medicine, 1992, 11: 55-66.
  3. Shih W. J., et al. Statistics in Medicine, 1997, 16: 1913-1923. (Shih's method based on Gould)
  4. Shih's method based on Chow.

No comments:

Post a Comment