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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 24 04:43:13 CET 2010


Author: keaven
Date: 2010-01-24 04:43:03 +0100 (Sun, 24 Jan 2010)
New Revision: 262

Modified:
   pkg/gsDesign/R/gsMethods.R
   pkg/gsDesign/R/nEvents.R
   pkg/gsDesign/man/nSurvival.Rd
Log:
Cleaned up final R CMD check warnings.

Modified: pkg/gsDesign/R/gsMethods.R
===================================================================
--- pkg/gsDesign/R/gsMethods.R	2010-01-23 21:29:15 UTC (rev 261)
+++ pkg/gsDesign/R/gsMethods.R	2010-01-24 03:43:03 UTC (rev 262)
@@ -241,30 +241,27 @@
         print(y)
     }
 }
-print.nSurvival <- function(x, med=FALSE, timeunit=""){
+print.nSurvival <- function(x,...){
 	if (class(x) != "nSurvival") stop("print.nSurvival: primary argument must have class nSurvival")
    cat("Fixed design, two-arm trial with time-to-event\n")
 	cat("outcome (Lachin and Foulkes, 1986).\n")
-	cat("Study duration (fixed):          Ts=", x$Ts, " ", timeunit, "\n", sep="")
-	cat("Accrual duration (fixed):        Tr=", x$Tr, " ", timeunit, "\n",sep="")
+	cat("Study duration (fixed):          Ts=", x$Ts, "\n", sep="")
+	cat("Accrual duration (fixed):        Tr=", x$Tr, "\n", sep="")
 	if (x$entry=="unif") cat('Uniform accrual:              entry="unif"\n')
 	else {
 		cat('Exponential accrual:          entry="expo"\n') 
 		cat("Accrual shape parameter:      gamma=", round(x$gamma,3), "\n",sep="")
 	}
-	if (med){
-		cat("Control median:      log(2)/lambda1=", round(log(2) / x$lambda1,1), " ", timeunit, "\n", sep="")
-		cat("Experimental median: log(2)/lambda2=", round(log(2) / x$lambda2,1), " ", timeunit, "\n", sep="")
-		if (x$eta > 0){
-			cat("Censoring only at study end (eta=0)\n")
-		}else{
-			cat("Censoring median:        log(2)/eta=", round(log(2) / x$eta, 1), " ", timeunit, "\n", sep="")
-		}
+	cat("Control median:      log(2)/lambda1=", round(log(2) / x$lambda1,1), "\n", sep="")
+	cat("Experimental median: log(2)/lambda2=", round(log(2) / x$lambda2,1), "\n", sep="")
+	if (x$eta > 0){
+		cat("Censoring only at study end (eta=0)\n")
 	}else{
-		cat("Control failure rate:       lambda1=", round(x$lambda1,3), "\n", sep="") 
-		cat("Experimental failure rate:  lambda2=", round(x$lambda2,3), "\n", sep="")
-		cat("Censoring rate:                 eta=", round(x$eta,3),"\n", sep="")
+		cat("Censoring median:        log(2)/eta=", round(log(2) / x$eta, 1), "\n", sep="")
 	}
+	cat("Control failure rate:       lambda1=", round(x$lambda1,3), "\n", sep="") 
+	cat("Experimental failure rate:  lambda2=", round(x$lambda2,3), "\n", sep="")
+	cat("Censoring rate:                 eta=", round(x$eta,3),"\n", sep="")
 	cat("Power:                 100*(1-beta)=", (1-x$beta)*100, "%\n",sep="")
    cat("Type I error (", x$sided, "-sided):   100*alpha=", 100*x$alpha, "%\n", sep="")
 	if (x$ratio==1) cat("Equal randomization:          ratio=1\n")

Modified: pkg/gsDesign/R/nEvents.R
===================================================================
--- pkg/gsDesign/R/nEvents.R	2010-01-23 21:29:15 UTC (rev 261)
+++ pkg/gsDesign/R/nEvents.R	2010-01-24 03:43:03 UTC (rev 262)
@@ -1,7 +1,7 @@
 "nEvents" <- function(hr = .6, alpha = .025, beta = .1, ratio = 1, sided = 1, hr0 =  1, n = 0, tbl = FALSE)
 {   c <- sqrt(ratio) / (1 + ratio)
     delta <- -c * (log(hr) - log(hr0))
-    if (n == 0)
+    if (n[1] == 0)
     {   n <- (qnorm(1-alpha)+qnorm(1-beta))^2/delta^2
         if (tbl) n <- cbind(hr, n = ceiling(n), alpha=alpha, beta=beta, Power=1-beta, delta=delta, 
                             ratio=ratio, se=sqrt(1/c/ceiling(n)))

Modified: pkg/gsDesign/man/nSurvival.Rd
===================================================================
--- pkg/gsDesign/man/nSurvival.Rd	2010-01-23 21:29:15 UTC (rev 261)
+++ pkg/gsDesign/man/nSurvival.Rd	2010-01-24 03:43:03 UTC (rev 262)
@@ -1,5 +1,6 @@
 \name{nSurvival}
 \alias{nSurvival}
+\alias{nEvents}
 \alias{print.nSurvival}
 \alias{Survival sample size}
 \title{3.4: Time-to-event sample size calculation (Lachin-Foulkes)}
@@ -10,7 +11,8 @@
 nSurvival(lambda1=1/12, lambda2=1/24, Ts=24, Tr=12, eta = 0, ratio = 1,
       alpha = 0.025, beta = 0.10, sided = 1, approx = FALSE,
       type = c("rr", "rd"), entry = c("unif", "expo"), gamma = NA)
-print.nSurvival(x, med=FALSE, timeunit="")
+print.nSurvival(x,...)
+nEvents(hr = .6, alpha = .025, beta = .1, ratio = 1, sided = 1, hr0 =  1, n = 0, tbl = FALSE)
 }
 \arguments{
   \item{lambda1, lambda2}{event hazard rate for placebo and treatment
@@ -21,7 +23,7 @@
   \item{Ts}{maximum study duration.}
   \item{Tr}{accrual (recruitment) duration.}
   \item{alpha}{type I error rate. Default is 0.05 since 2-sided testing is default.}
-  \item{beta}{type II error rate. Default is 0.10 (90\% power).}
+  \item{beta}{type II error rate. Default is 0.10 (90\% power). Not needed for \code{nEvents()} if n is provided.}
   \item{sided}{one or two-sided test? Default is two-sided test.}
   \item{approx}{logical. If \code{TRUE}, the approximation sample size
     formula for risk difference is used.}
@@ -32,14 +34,17 @@
   \item{gamma}{rate parameter for exponential entry. \code{NA} if entry type is
     \code{"unif"} (uniform). A non-zero value is supplied if entry type is
     \code{"expo"} (exponential).} 
-  \item{x}{An object of class "nSurvival" returned by \code{nSurvival()}}
-  \item{med}{If true, median time-to-event is printed rather than failure rate.}
-  \item{timeunit}{Character string indicating time units for event rates
+  \item{x}{An object of class "nSurvival" returned by \code{nSurvival()}
    (optional: used for output; "months" or "years" would be the 'usual' choices).}
+  \item{hr}{Hazard ratio under the alternative hypothesis (>0).}
+  \item{hr0}{Hazard ratio under the null hypothesis (>0, != \code{hr}).}
+  \item{n}{Number of events may be input to compute power rather than sample size.}
+  \item{tbl}{Indicator of whether or not scalar (vector) or tabular output is desired for \code{nEvents()}.}
+  \item{...}{Allows additional arguments for \code{print.nSurvival()}.}
 }
 
 \details{
-  \code{nSurvival} produces an object of class "nSurvival" with 
+  \code{nSurvival()} produces an object of class "nSurvival" with 
   the number of subjects and events for a set of
   pre-specified trial parameters, such as accrual duration and follow-up
   period. The calculation is based on Lachin and Foulkes (1986) method and can
@@ -51,6 +56,8 @@
   For non-uniform entry, a non-zero value of gamma for exponential entry
   must be supplied. For positive gamma, the entry distribution is
   convex, whereas for negative gamma, the entry distribution is concave.
+
+  \code{nEvents()} uses the Schoenfeld (1981) method to approximate the number of events \code{n} (given \code{beta}) or the power (given \code{n}). Arguments may be vectors or scalars, but any vectors must have the same length.
 }
 
 \value{
@@ -69,6 +76,16 @@
   \item{sided}{As input.}
   \item{Ts}{As input.}
   \item{Tr}{As input.}
+
+  \code{nEvents} produces a scalar or vector of sample sizes (or powers) when \code{tbl=FALSE} or, when \code{tbl=TRUE} a matrix of values with the following columns:
+  \item{hr}{As input.}
+  \item{n}{If \code{n[1]=0} on input (default), output contains the number of events need to obtain the input Type I and II error. If \code{n[1]>0} on input, the input value is returned.}
+  \item{alpha}{As input.}
+  \item{beta}{If \code{n[1]=0} on input (default), \code{beta} is output as input. Otherwise, this is the computed Type II error based on the input \code{n}.}
+  \item{Power}{One minus the output \code{beta}. When \code{tbl=FALSE, n[1]>0}, this is the value or vector of values returned.}
+  \item{delta}{Standardized effect size represented by input difference between null and alternative hypothesis hazard ratios.}
+  \item{ratio}{Ratio of experimental to control sample size where 'experimental' is the same as the group with hazard represented in the numerator of the hazard ratio.}
+  \item{se}{Estimated standard error for the observed log(hazard ratio) with the given sample size.}
 }
 \seealso{\link{gsDesign package overview}, \link{Plots for group sequential designs}, \link{gsDesign}} 
 \author{Shanhong Guan \email{shanhong\_guan at merck.com}}
@@ -77,6 +94,10 @@
   Evaluation of Sample Size and Power for Analyses of Survival
   with Allowance for Nonuniform Patient Entry, Losses to Follow-Up,
   Noncompliance, and Stratification. \emph{Biometrics}, 42, 507-519.
+
+  Schoenfeld D (1981),
+  The Asymptotic Properties of Nonparametric Tests for Comparing Survival Distributions. \emph{Biometrika}, 
+  68, 316-319. 
 }
 
 \examples{
@@ -106,6 +127,18 @@
    x$n.I
 # print the design
 x
+
+# approximate number of events required using Schoenfeld's method
+# for 2 different hazard ratios
+nEvents(hr=c(.5, .6), tbl=TRUE)
+# vector output
+nEvents(hr=c(.5, .6))
+
+# approximate power using Schoenfeld's method
+# given 2 sample sizes and hr=.6
+nEvents(hr=.6, n=c(50, 100), tbl=TRUE)
+# vector output
+nEvents(hr=.6, n=c(50, 100))
 }
 
 \keyword{design}



More information about the Gsdesign-commits mailing list