[Gsdesign-commits] r369 - in pkg/gsDesign: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 26 03:52:08 CEST 2014


Author: keaven
Date: 2014-05-26 03:52:07 +0200 (Mon, 26 May 2014)
New Revision: 369

Modified:
   pkg/gsDesign/DESCRIPTION
   pkg/gsDesign/NAMESPACE
   pkg/gsDesign/R/gsCP.R
   pkg/gsDesign/R/gsDesign.R
   pkg/gsDesign/man/gsDesign.Rd
   pkg/gsDesign/man/gsProbability.Rd
Log:
Added overrun computations to expected sample size; updated help files for gsDesign, gsProbability

Modified: pkg/gsDesign/DESCRIPTION
===================================================================
--- pkg/gsDesign/DESCRIPTION	2014-05-24 12:44:12 UTC (rev 368)
+++ pkg/gsDesign/DESCRIPTION	2014-05-26 01:52:07 UTC (rev 369)
@@ -1,5 +1,5 @@
 Package: gsDesign
-Version: 2.8-9
+Version: 2.9
 Title: Group Sequential Design
 Author: Keaven Anderson 
 Maintainer: Keaven Anderson <keaven_anderson at merck.com>

Modified: pkg/gsDesign/NAMESPACE
===================================================================
--- pkg/gsDesign/NAMESPACE	2014-05-24 12:44:12 UTC (rev 368)
+++ pkg/gsDesign/NAMESPACE	2014-05-26 01:52:07 UTC (rev 369)
@@ -1,4 +1,5 @@
 useDynLib(gsDesign)
+import(RUnit,ggplot2,plyr,stringr,xtable)
 export(gsBoundCP, gsCP, gsPP, gsPI, gsPOS, gsCPOS, gsDensity, gsPosterior)
 export(gsCPz, gsHR, gsDelta, gsBValue, gsRR, hrn2z, hrz2n, zn2hr)
 export(gsBound, gsBound1, gsDesign, gsProbability)

Modified: pkg/gsDesign/R/gsCP.R
===================================================================
--- pkg/gsDesign/R/gsCP.R	2014-05-24 12:44:12 UTC (rev 368)
+++ pkg/gsDesign/R/gsCP.R	2014-05-26 01:52:07 UTC (rev 369)
@@ -71,7 +71,7 @@
         anew <- array(-20, knew)
     }
     
-    gsProbability(k=knew, theta=theta, n.I=Inew, a=anew, b=bnew, r=r)
+    gsProbability(k=knew, theta=theta, n.I=Inew, a=anew, b=bnew, r=r, overrun=0)
 }
 
 gsPP <- function(x, i=1, zi=0, theta=c(0,3), wgts=c(.5,.5), r=18, total=TRUE)

Modified: pkg/gsDesign/R/gsDesign.R
===================================================================
--- pkg/gsDesign/R/gsDesign.R	2014-05-24 12:44:12 UTC (rev 368)
+++ pkg/gsDesign/R/gsDesign.R	2014-05-26 01:52:07 UTC (rev 369)
@@ -227,8 +227,9 @@
         return(gsDProb(theta=theta, d=d))
     }
     
-    # check remaingin input arguments
-    checkVector(overrrun,length=k-1,interval=c(0,Inf),include=c(TRUE,FALSE))
+    # check remaining input arguments
+    checkVector(x=overrun,isType="numeric",interval=c(0,Inf),inclusion=c(TRUE,FALSE))
+    if(length(overrun)!= 1 && length(overrun)!= k-1) stop(paste("overrun length should be 1 or ",as.character(k-1)))
     checkScalar(r, "integer", c(1,80))
     checkLengths(n.I, a, b)
     if (k != length(a))
@@ -249,7 +250,9 @@
     phi <- matrix(xx[[8]], k, ntheta)
     powr <- as.vector(array(1, k) %*% phi)
     futile <- array(1, k) %*% plo
-    nOver <- c(n.I[1:(k-1)]+overrun,n.I[k])
+    if(k==1){nOver <- n.I[k]}else{
+      nOver <- c(n.I[1:(k-1)]+overrun,n.I[k])
+    }
     nOver[nOver>n.I[k]] <- n.I[k]
     en <- as.vector(nOver %*% (plo + phi) + n.I[k] * (t(array(1, ntheta)) - powr - futile))
     x <- list(k=xx[[1]], theta=xx[[3]], n.I=xx[[4]], lower=list(bound=xx[[5]], prob=plo), 
@@ -429,7 +432,7 @@
     }
     
     x$theta <- c(0, x$delta)
-    y <- gsprob(x$theta, x$n.I, x$lower$bound, x$upper$bound, r=x$r, overrun=overrun)
+    y <- gsprob(x$theta, x$n.I, x$lower$bound, x$upper$bound, r=x$r, overrun=x$overrun)
     x$upper$prob <- y$probhi
     x$lower$prob <- y$problo
     x$en <- as.vector(y$en)
@@ -636,7 +639,7 @@
     
     # add boundary crossing probabilities for theta to x
     x$theta <- c(0,x$delta)
-    x4 <- gsprob(x$theta,x$n.I,x$lower$bound,x$upper$bound,overrun=overrun)
+    x4 <- gsprob(x$theta,x$n.I,x$lower$bound,x$upper$bound,overrun=x$overrun)
     x$upper$prob <- x4$probhi
     x$lower$prob <- x4$problo
     x$en <- as.vector(x4$en)
@@ -683,7 +686,7 @@
 
     # add boundary crossing probabilities for theta to x
     x$theta <- c(0, x$delta)
-    x4 <- gsprob(x$theta, x$n.I, -x2$b, x1$b, overrun=overrun)
+    x4 <- gsprob(x$theta, x$n.I, -x2$b, x1$b, overrun=x$overrun)
     x$upper$prob <- x4$probhi
     x$lower$prob <- x4$problo
     x$en <- as.vector(x4$en)
@@ -800,7 +803,7 @@
     # compute error rates needed and add to x
     x$theta <- c(0,x$delta)
     x$falseposnb <- as.vector(gsprob(0, x$n.I, array(-20, x$k), x$upper$bound,r =x$r)$probhi)
-    x3 <- gsprob(x$theta, x$n.I, x$lower$bound, x$upper$bound, r=x$r, overrun=overrun)
+    x3 <- gsprob(x$theta, x$n.I, x$lower$bound, x$upper$bound, r=x$r, overrun=x$overrun)
     x$upper$prob <- x3$probhi
     x$lower$prob <- x3$problo
     x$en <- as.vector(x3$en)
@@ -896,8 +899,8 @@
     powr <- array(1, nanal)%*%phi
     futile <- array(1, nanal)%*%plo
     IOver <- c(I[1:(nanal-1)]+overrun,I[nanal])
-    IOver[IOver>I[nanal]]<-nanal
-    en <- IOver %*% (plo+phi) + I[nanal] * (t(array(1, ntheta)) - powr - futile)
+    IOver[IOver>I[nanal]]<-I[nanal]
+    en <- as.vector(IOver %*% (plo+phi) + I[nanal] * (t(array(1, ntheta)) - powr - futile))
     list(k=xx[[1]], theta=xx[[3]], I=xx[[4]], a=xx[[5]], b=xx[[6]], problo=plo, 
             probhi=phi, powr=powr, en=en, r=r)
 }
@@ -921,7 +924,12 @@
     phi <- matrix(xx[[8]], k, ntheta)
     powr <- as.vector(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))
+    if (k==1){IOver <- n.I}else{
+      IOver <- c(n.I[1:(k-1)]+d$overrun,n.I[k])
+    }
+    IOver[IOver>n.I[k]]<-n.I[k]
+    en <- as.vector(IOver %*% (plo+phi) + n.I[k] * (t(array(1, ntheta)) - powr - futile))
+
     d$en <- en
     d$theta <- theta
     d$upper$prob <- phi
@@ -1046,7 +1054,8 @@
     x$r <- as.integer(x$r)
     
     # check overrun vector
-    checkVector(x$overrun,length(x$k-1),interval=c(0,Inf),inclusion=c(TRUE,FALSE))
+    checkVector(x$overrun,interval=c(0,Inf),inclusion=c(TRUE,FALSE))
+    if(length(x$overrun)!= 1 && length(x$overrun)!= x$k-1) stop(paste("overrun length should be 1 or ",as.character(x$k-1)))
   
     x
 }

Modified: pkg/gsDesign/man/gsDesign.Rd
===================================================================
--- pkg/gsDesign/man/gsDesign.Rd	2014-05-24 12:44:12 UTC (rev 368)
+++ pkg/gsDesign/man/gsDesign.Rd	2014-05-26 01:52:07 UTC (rev 369)
@@ -6,7 +6,7 @@
 gsDesign(k=3, test.type=4, alpha=0.025, beta=0.1, astar=0,  
          delta=0, n.fix=1, timing=1, sfu=sfHSD, sfupar=-4,
          sfl=sfHSD, sflpar=-2, tol=0.000001, r=18, n.I = 0,
-         maxn.IPlan = 0, nFixSurv=0, endpoint=NULL, delta1=1, delta0=0)
+         maxn.IPlan = 0, nFixSurv=0, endpoint=NULL, delta1=1, delta0=0,overrun=0)
 }
 \arguments{
 	\item{k}{Number of analyses planned, including interim and final.}
@@ -60,6 +60,7 @@
 
 	\item{delta1}{\code{delta1} and \code{delta0} may be used to store information about the natural parameter scale compared to \code{delta} that is a standardized effect size. \code{delta1} is the alternative hypothesis parameter value on the natural parameter scale (e.g., the difference in two binomial rates).}
   \item{delta0}{\code{delta0} is the null hypothesis parameter value on the natural parameter scale.}
+  \item{overrun}{Scalar or vector of length \code{k-1} with patients enrolled that are not included in each interim analysis.}
 }
 \value{
 An object of the class \code{gsDesign}. This class has the following elements and upon return from 
@@ -77,21 +78,27 @@
 \item{timing}{A vector of length \code{k} containing the portion of the total planned information or sample size at each analysis.}
 \item{tol}{As input.}
 \item{r}{As input.}
-\item{upper}{Upper bound spending function, boundary and boundary crossing probabilities under the NULL and
-alternate hypotheses. See \link{Spending function overview} and manual for further details.}
-\item{lower}{Lower bound spending function, boundary and boundary crossing probabilities at each analysis.
-Lower spending is under alternative hypothesis (beta spending) for \code{test.type=3} or \code{4}. 
-For \code{test.type=2}, \code{5} or \code{6}, lower spending is under the null hypothesis.
-For \code{test.type=1}, output value is \code{NULL}. See \link{Spending function overview} and manual.}
 \item{n.I}{Vector of length \code{k}. If values are input, same values are output.
 Otherwise, \code{n.I} will contain the sample size required at each analysis 
 to achieve desired \code{timing} and \code{beta} for the output value of \code{delta}. 
 If \code{delta=0} was input, then this is the sample size required for the specified group sequential design when a fixed design requires a sample size of \code{n.fix}.
 If \code{delta=0} and \code{n.fix=1} then this is the relative sample size compared to a fixed design; see details and examples.}
 \item{maxn.IPlan}{As input.}
+\item{nFixSurv}{As input.}
+\item{nSurv}{Sample size for Lachin and Foulkes method when \code{nSurvival} is used for fixed design input. If \code{nSurvival} is used to compute \code{n.fix}, then \code{nFixSurv} is inflated by the same amount as \code{n.fix} and stored in \code{nSurv}. Note that if you use \code{gsSurv} for time-to-event sample size, this is not needed and a more complete output summary is given.}
 \item{endpoint}{As input.}
 \item{delta1}{As input.}
 \item{delta0}{As input.}
+\item{overrun}{As input.}
+\item{upper}{Upper bound spending function, boundary and boundary crossing probabilities under the NULL and
+alternate hypotheses. See \link{Spending function overview} and manual for further details.}
+\item{lower}{Lower bound spending function, boundary and boundary crossing probabilities at each analysis.
+Lower spending is under alternative hypothesis (beta spending) for \code{test.type=3} or \code{4}. 
+For \code{test.type=2}, \code{5} or \code{6}, lower spending is under the null hypothesis.
+For \code{test.type=1}, output value is \code{NULL}. See \link{Spending function overview} and manual.}
+\item{theta}{Standarized effect size under null (0) and alternate hypothesis. If \code{delta} is input, \code{theta[1]=delta}. If \code{n.fix} is input, \code{theta[1]} is computed using a standard sample size formula (pseudocode): \code{((Zalpha+Zbeta)/theta[1])^2=n.fix}.}
+\item{falseprobnb}{For \code{test.type=4} or \code{6}, this contains false positive probabilities under the null hypothesis assuming that crossing a futility bound does not stop the trial.}
+\item{en}{Expected sample size accounting for early stopping. For time-to-event outcomes, this would be the expected number of events (although \code{gsSurv} will give expected sample size). For information-based-design, this would give the expected information when the trial stops. If \code{overrun} is specified, the expected sample size includes the overrun at each interim.}
 }
 \details{
 Many parameters normally take on default values and thus do not require explicit specification.

Modified: pkg/gsDesign/man/gsProbability.Rd
===================================================================
--- pkg/gsDesign/man/gsProbability.Rd	2014-05-24 12:44:12 UTC (rev 368)
+++ pkg/gsDesign/man/gsProbability.Rd	2014-05-26 01:52:07 UTC (rev 369)
@@ -8,7 +8,7 @@
 }
 
 \usage{
-gsProbability(k=0, theta, n.I, a, b, r=18, d=NULL)
+gsProbability(k=0, theta, n.I, a, b, r=18, d=NULL, overrun=0)
 \method{print}{gsProbability}(x,\dots)
 }
 \details{Depending on the calling sequence, an object of class \code{gsProbability} or class \code{gsDesign} is returned.
@@ -34,6 +34,7 @@
 	When this is specified, the values of \code{k}, \code{n.I}, \code{a}, \code{b}, and \code{r} will be obtained from \code{d} and
 	only \code{theta} needs to be specified by the user.}
   \item{x}{An item of class \code{gsProbability}.}
+  \item{overrun}{Scalar or vector of length \code{k-1} with patients enrolled that are not included in each interim analysis.}
   \item{\dots}{Not implemented (here for compatibility with generic print input).}
 }
 \value{



More information about the Gsdesign-commits mailing list