[Gsdesign-commits] r180 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 28 15:54:09 CEST 2009


Author: keaven
Date: 2009-08-28 15:54:09 +0200 (Fri, 28 Aug 2009)
New Revision: 180

Added:
   pkg/R/gsBinomialExact.R
   pkg/man/gsBinomialExact.Rd
Modified:
   pkg/NAMESPACE
   pkg/man/binomial.Rd
   pkg/man/nSurvival.Rd
Log:
Adding exact binomial group sequential probability calculations in gsBinomialExact

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2009-08-28 13:41:38 UTC (rev 179)
+++ pkg/NAMESPACE	2009-08-28 13:54:09 UTC (rev 180)
@@ -1,7 +1,7 @@
 useDynLib(gsDesign)
 export(gsBoundCP, gsCP)
 export(gsBound, gsBound1, gsDesign, gsProbability)
-export(ciBinomial, nBinomial, simBinomial, testBinomial)
+export(ciBinomial, nBinomial, simBinomial, testBinomial, gsBinomialExact)
 export(nSurvival)
 export(normalGrid)
 export(plot.gsDesign, plot.gsProbability, print.gsProbability, print.gsDesign)

Added: pkg/R/gsBinomialExact.R
===================================================================
--- pkg/R/gsBinomialExact.R	                        (rev 0)
+++ pkg/R/gsBinomialExact.R	2009-08-28 13:54:09 UTC (rev 180)
@@ -0,0 +1,62 @@
+gsBinomialExact <- function(k=2, theta=c(.1, .2), n.I=c(50, 100), a=c(3, 7), b=c(20,30))
+{
+    checkScalar(k, "integer", c(2,Inf), inclusion=c(TRUE, FALSE))
+    checkVector(theta, "numeric", interval=0:1, inclusion=c(TRUE, TRUE))
+    checkVector(n.I, "integer", interval=c(1, Inf), inclusion=c(TRUE, FALSE))
+    checkVector(a, "integer", interval=c(-Inf, Inf), inclusion=c(FALSE, FALSE))
+    checkVector(b, "integer", interval=c(1, Inf), inclusion=c(FALSE, FALSE))
+    ntheta <- as.integer(length(theta))
+    theta <- as.real(theta)
+    if (k != length(n.I) || k!=length(a) || k != length(b))
+        stop("Lengths of n.I, a, and b must equal k on input")
+    m <- c(n.I[1], diff(n.I))
+    if (min(m) < 1) stop("n.I must must contain an increasing sequence of positive integers")
+    if (min(n.I-a) < 0) stop("Input a-vector must be less than n.I")
+    if (min(b-a) <= 0) stop("Input b-vector must be strictly greater than a")
+    if (min(diff(a)) < 0) stop("a must contain a non-decreasing sequence of integers")
+    if (min(diff(b)) < 0) stop("b must contain a non-decreasing sequence of integers")
+    if (min(diff(n.I-b)) < 0)  stop("n.I - b must be non-decreasing")
+      
+    plo <- matrix(nrow=k, ncol = ntheta)
+    rownames(plo) <- paste(array("Analysis ", k), 1:k)
+    colnames(plo) <- theta
+    phi <- plo
+    en <- numeric(ntheta)
+
+    for(h in 1:length(theta))
+    {
+        p <- theta[h]
+
+        ### c.mat is the recursive function defined in (12.5)
+        ### plo and phi are the probabilities of crossing the lower and upper boundaries defined in (12.6)
+        c.mat <- matrix(0, ncol=k, nrow=n.I[k]+1)
+        for(i in 1:k)
+        {
+            if(i==1)
+            {
+                c.mat[,1] <- dbinom(0:n.I[k], m[1], p)
+            }
+            else
+            {
+                no.stop <- (a[i-1]+1):(b[i-1]-1)
+                no.stop.mat <- matrix(no.stop, byrow=T, nrow=n.I[k]+1, ncol=length(no.stop))
+                succ.mat <- matrix(0:n.I[k], byrow=F, ncol=length(no.stop), nrow=n.I[k]+1)
+                bin.mat <- matrix(dbinom(succ.mat-no.stop.mat, m[i], p),byrow=F,ncol=length(no.stop), nrow=n.I[k]+1)
+                c.mat[,i] <- bin.mat %*% c.mat[no.stop+1,(i-1)] 
+            }
+            plo[i,h] <- sum(c.mat[(0:n.I[k]) <= a[i], i])
+            phi[i,h] <- sum(c.mat[(0:n.I[k]) >= b[i], i])
+        }
+    }
+  
+    powr <-   array(1, k) %*% phi
+    futile <- array(1, k) %*% plo
+    en <- as.vector(n.I %*% (plo + phi) + n.I[k] * (t(array(1,ntheta)) - powr - futile))
+
+    x <- list(k = k, theta = theta, n.I = n.I, 
+         lower = list(bound = a, prob = plo ),
+         upper = list(bound = b, prob = phi ), en=en)
+
+    class(x) <- c("gsBinomialExact", "gsProbability")
+    return(x)
+}

Modified: pkg/man/binomial.Rd
===================================================================
--- pkg/man/binomial.Rd	2009-08-28 13:41:38 UTC (rev 179)
+++ pkg/man/binomial.Rd	2009-08-28 13:54:09 UTC (rev 180)
@@ -66,7 +66,7 @@
 }
 \item{ratio}{sample size ratio for group 2 divided by group 1}
 \item{sided}{2 for 2-sided test, 1 for 1-sided test}
-\item{outtype}{\code{nBinomial} only; (default) returns total sample size; 2 returns sample size for each group (\code{n1, n2});
+\item{outtype}{\code{nBinomial} only; (default) returns total sample size; 2 returns sample size for each group (\code{n1, n2}; 3 returns additional interim calculations);
 3 and \code{delta0=0} returns a list with total sample size (\code{n}), sample size in each group (\code{n1, n2}),
 null and alternate hypothesis variance (\code{sigma0, sigma1}), input event rates (\code{p1, p2}) and null hypothesis event
 rates (\code{p10, p20}). 

Added: pkg/man/gsBinomialExact.Rd
===================================================================
--- pkg/man/gsBinomialExact.Rd	                        (rev 0)
+++ pkg/man/gsBinomialExact.Rd	2009-08-28 13:54:09 UTC (rev 180)
@@ -0,0 +1,56 @@
+\name{gsBinomialExact}
+\alias{gsBinomialExact}
+\title{2.7: One-Sample Exact Binomial Boundary Crossing Probabilities}
+\description{Computes power/Type I error and expected sample size for a group sequential design
+in a single-arm trial with a binary outcome.
+The print function has been extended using \code{print.gsBinomialExact} to print \code{gsBinomialExact} objects; see examples.
+}
+
+\usage{
+gsBinomialExact(k=2, theta=c(.1, .2), n.I=c(50, 100), a=c(3, 7), b=c(20,30))
+}
+\arguments{
+	\item{k}{Number of analyses planned, including interim and final.}
+	\item{theta}{Vector of possible underling binomial probabilities for a single binomial sample.}
+	\item{n.I}{Sample size at analyses (increasing positive integers); vector of length k.}
+	\item{a}{Number of "successes" required to cross lower bound cutoffs for futility or harm at each analysis; vector of length k; -1 means no lower bound.}
+	\item{b}{Number of "successes" required to cross upper bound cutoffs for futility or harm at each analysis; vector of length k.}
+}
+\details{
+Based on the book "Group Sequential Methods with Applications to Clinical Trials,"
+Christopher Jennison and Bruce W. Turnbull, Chapter 12, Section 12.1.2 Exact Calculations for Binary Data.
+This computation is often used as an approximation for the distribution of the number of events in one treatment group out of all events when the probability of an event is small and sample size is large.
+
+An object of class \code{gsBinomialExact} is returned.
+On output, the values of \code{theta} input to \code{gsBinomialExact} will be the parameter values for which the boundary crossing probabilities and expected sample sizes are computed.
+
+Note that a[1] equal to -1 lower bound at n.I[1] means 0 successes continues at interim 1; a[2]==0 at interim 2 means 0 successes stops trial for futility at 2nd analysis. 
+For final analysis, set a[k] equal to b[k]-1 to incorporate all possibilities into non-positive trial; see example.  
+}
+
+\value{
+	\item{k}{As input.}
+	\item{theta}{As input.}
+	\item{n.I}{As input.}
+	\item{lower}{A list containing two elements: \code{bound} is as input in \code{a} and \code{prob} is a matrix of boundary 
+	crossing probabilities. Element \code{i,j} contains the boundary crossing probability at analysis \code{i} for the \code{j}-th element of \code{theta} input. All boundary crossing is assumed to be binding for this computation; that is, the trial must stop if a boundary is crossed.}
+	\item{upper}{A list of the same form as \code{lower} containing the upper bound and upper boundary crossing probabilities.}
+	\item{en}{A vector of the same length as \code{theta} containing expected sample sizes for the trial design
+	corresponding to each value in the vector \code{theta}.}
+}
+\seealso{\code{\link{gsProbability}}}
+\note{The manual is not linked to this help file, but is available in library/gsdesign/doc/gsDesignManual.pdf
+in the directory where R is installed.}
+\author{Jon Hartzel with modifications for gsDesign package by Yevgen Tymofyeyev and Keaven Anderson \email{keaven\_anderson at merck.}}
+\references{
+Jennison C and Turnbull BW (2000), \emph{Group Sequential Methods with Applications to Clinical Trials}.
+Boca Raton: Chapman and Hall.
+} 
+
+\examples{
+
+zz <- gsBinomialExact(k=3,theta=seq(0,1,0.1), n.I=c(12,24,36),
+        a=c(-1, 0, 11),  b=c( 5, 9, 12))
+zz
+}
+\keyword{design}

Modified: pkg/man/nSurvival.Rd
===================================================================
--- pkg/man/nSurvival.Rd	2009-08-28 13:41:38 UTC (rev 179)
+++ pkg/man/nSurvival.Rd	2009-08-28 13:54:09 UTC (rev 180)
@@ -1,7 +1,7 @@
 \name{nSurvival}
 \alias{nSurvival}
 \alias{Survival sample size}
-\title{3.3: Time-to-event sample size calculation (Lachin-Foulkes)}
+\title{3.4: Time-to-event sample size calculation (Lachin-Foulkes)}
 \description{\code{nSurvival()} is used to calculate the sample size for a clinical trial with a time-to-event endpoint. The Lachin and Foulkes (1986) method is used.
 }
 



More information about the Gsdesign-commits mailing list