From noreply at r-forge.r-project.org Sat Aug 29 17:45:15 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 29 Aug 2015 17:45:15 +0200 (CEST) Subject: [Gsdesign-commits] r378 - in pkg/gsDesign: R man Message-ID: <20150829154515.812F11876E0@r-forge.r-project.org> Author: keaven Date: 2015-08-29 17:45:14 +0200 (Sat, 29 Aug 2015) New Revision: 378 Modified: pkg/gsDesign/R/gsSurv.R pkg/gsDesign/R/nBinomial1Sample.r pkg/gsDesign/man/gsBinomialExact.Rd Log: Updated nBinomial1Sample; fixed nEventsIA (and thus tEventsIA) to work with stratified populations when simple=TRUE is specified; did not appear to impact other things. Modified: pkg/gsDesign/R/gsSurv.R =================================================================== --- pkg/gsDesign/R/gsSurv.R 2015-07-30 00:53:33 UTC (rev 377) +++ pkg/gsDesign/R/gsSurv.R 2015-08-29 15:45:14 UTC (rev 378) @@ -558,7 +558,9 @@ Tfinal=x$T[length(x$T)], minfup=x$minfup) if (simple) { if (class(x)[1] == "gsSize") d<-x$d - else d <- sum(x$eDC[length(x$eDC)]+x$eDE[length(x$eDE)]) +#OLD else d <- sum(x$eDC[length(x$eDC)]+x$eDE[length(x$eDE)]) + else if(!is.matrix(x$eDC)) d <- sum(x$eDC[length(x$eDC)]+x$eDE[length(x$eDE)]) + else d <- sum(x$eDC[nrow(x$eDC),]+x$eDE[nrow(x$eDE),]) return(sum(eDC$d+eDE$d)-target*d) } else return(list(T=tIA,eDC=eDC$d,eDE=eDE$d,eNC=eDC$n,eNE=eDE$n)) Modified: pkg/gsDesign/R/nBinomial1Sample.r =================================================================== --- pkg/gsDesign/R/nBinomial1Sample.r 2015-07-30 00:53:33 UTC (rev 377) +++ pkg/gsDesign/R/nBinomial1Sample.r 2015-08-29 15:45:14 UTC (rev 378) @@ -16,20 +16,19 @@ # proportion Power <- pbinom(CritVal - 1, n, p1, lower.tail=FALSE) bta <- 1 - Power - if (outtype==3 || is.null(beta)) return(data.frame(p0=p0, p1=p1, - alpha=Alpha, beta=bta, - Power=Power, n=n, b=CritVal)) + if (is.null(beta)) beta <- bta + if (outtype==3 || is.null(beta)) return(data.frame(p0=p0, p1=p1, alpha=alpha, beta=beta, + n=n, b=CritVal, + alphaR=Alpha, Power=Power)) if (max(Power)= Pow)) }else if (min(Power >= Pow)==1){SampSize=1 }else SampSize <- max(which(Power < Pow)) + 1 - if (outtype==2) return(data.frame(p0=p0, p1=p1, alpha=Alpha[SampSize],beta=beta, - n=SampSize,b=CritVal[SampSize], - alphaR=Alpha[SampSize], Power=Power[SampSize])) + if (outtype==2) return(data.frame(p0=p0, p1=p1, alpha=alpha, beta=beta, + n=n[SampSize], b=CritVal[SampSize], + alphaR=Alpha[SampSize], Power=Power[SampSize])) return(n[SampSize]) } - - - Modified: pkg/gsDesign/man/gsBinomialExact.Rd =================================================================== --- pkg/gsDesign/man/gsBinomialExact.Rd 2015-07-30 00:53:33 UTC (rev 377) +++ pkg/gsDesign/man/gsBinomialExact.Rd 2015-08-29 15:45:14 UTC (rev 378) @@ -35,12 +35,12 @@ \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.} + \item{a}{Number of "successes" required to cross lower bound cutoffs to reject \code{p1} in favor of \code{p0} at each analysis; vector of length k; -1 means no lower bound.} + \item{b}{Number of "successes" required to cross upper bound cutoffs for rejecting \code{p0} in favor of \code{p1} at each analysis; vector of length k.} \item{p0}{Lower of the two response (event) rates hypothesized.} \item{p1}{Higher of the two response (event) rates hypothesized.} - \item{alpha}{Nominal probability of rejecting response (event) rate \code{p0} when it is true (Type I error rate).} - \item{beta}{Nominal probability of rejecting response (event) rate \code{p1} when it is true (Type II error rate).} + \item{alpha}{Nominal probability of rejecting response (event) rate \code{p0} when it is true.} + \item{beta}{Nominal probability of rejecting response (event) rate \code{p1} when it is true.} \item{minn}{Minimum sample size at which sequential testing begins.} \item{maxn}{Maximum sample size.} \item{x}{Item of class \code{gsBinomialExact} or \code{binomialSPRT} for \code{print.gsBinomialExact}. Item of class \code{gsBinomialExact} for \code{plot.gsBinomialExact}. Item of class \code{binomialSPRT} for item of class \code{binomialSPRT}.} @@ -63,8 +63,10 @@ The sequential probability ratio test (SPRT) is a sequential testing scheme allowing testing after each observation. This likelihood ratio is used to determine upper and lower cutoffs which are linear and parallel in the number of responses as a function of sample size. \code{binomialSPRT} produces a variation the the SPRT that tests only within a range of sample sizes. -While the linear SPRT bounds are continuous, actual bounds are the integer number of response at or beyond each linear bound for each sample size where testing is performed. Because of the truncation and discretization of the bounds, power and Type I error achieve will be lower than the nominal levels specified by \code{alpha} and \code{beta} which can be altered to produce desired values that are achieved by the planned sample size. See also example that shows computation of Type I error when futility bound is considered non-binding. +While the linear SPRT bounds are continuous, actual bounds are the integer number of response at or beyond each linear bound for each sample size where testing is performed. Because of the truncation and discretization of the bounds, power and Type I error achieve will be lower than the nominal levels specified by \code{alpha} and \code{beta} which can be altered to produce desired values that are achieved by the planned sample size. See also example that shows computation of Type I error when futility bound is considered non-binding. +Note that if the objective of a design is to demonstrate that a rate (e.g., failure rate) is lower than a certain level, two approaches can be taken. First, 1 minus the failure rate is the success rate and this can be used for planning. Second, the role of \code{beta} becomes to express Type I error and \code{alpha} is used to express Type II error. + Plots produced include boundary plots, expected sample size, response rate at the boundary and power. \code{gsBinomial1Sample} uses exact binomial computations based on the base R functions \code{qbinom()} and \code{pbinom()}. The tabular output may be convenient for plotting. Note that input variables are largely not checked, so the user is largely responsible for results; it is a good idea to do a run with \code{outtype=3} to check that you have done things appropriately. @@ -92,15 +94,15 @@ \item{p1}{As input.} \code{nBinomial1Sample} produces an integer if the input \code{outtype=1} and a data frame with the following values otherwise: -\item{p0}{input null hypothesis event (or response) rate.} -\item{p1}{input alternative hypothesis (or response) rate; must be \code{> p0}.} -\item{alpha}{Type I error achieved for each output value of \code{n}; less than or equal to the input value \code{alpha}.} -\item{beta}{Type II error achieved for each output value of \code{n}.} -\item{Power}{\code{1} minus the output \code{beta} value.} +\item{p0}{Input null hypothesis event (or response) rate.} +\item{p1}{Input alternative hypothesis (or response) rate; must be \code{> p0}.} +\item{alpha}{Input Type I error.} +\item{beta}{Input Type II error except when input is \code{NULL} in which case realized Type II error is computed.} +\item{alphaR}{Type I error achieved for each output value of \code{n}; less than or equal to the input value \code{alpha}.} +\item{Power}{Power achived for each output value of \code{n}.} \item{n}{sample size.} \item{b}{cutoff given \code{n} to control Type I error; value is \code{NULL} if no such value exists.} -Note that when the input \code{1 > beta > alpha > 0} from the input \code{n} for which the power is at least \code{1-beta} or \code{NULL} if no input sample size satisfies the desired. } \seealso{\code{\link{gsProbability}}}