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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 12 23:31:36 CET 2011


Author: keaven
Date: 2011-12-12 23:31:36 +0100 (Mon, 12 Dec 2011)
New Revision: 325

Modified:
   pkg/gsDesign/DESCRIPTION
   pkg/gsDesign/R/nEvents.R
Log:
Fixed sided=2 for nEvents

Modified: pkg/gsDesign/DESCRIPTION
===================================================================
--- pkg/gsDesign/DESCRIPTION	2011-12-04 14:24:57 UTC (rev 324)
+++ pkg/gsDesign/DESCRIPTION	2011-12-12 22:31:36 UTC (rev 325)
@@ -1,5 +1,5 @@
 Package: gsDesign
-Version: 2.6
+Version: 2.6-01
 Title: Group Sequential Design
 Author: Keaven Anderson 
 Maintainer: Keaven Anderson <keaven_anderson at merck.com>

Modified: pkg/gsDesign/R/nEvents.R
===================================================================
--- pkg/gsDesign/R/nEvents.R	2011-12-04 14:24:57 UTC (rev 324)
+++ pkg/gsDesign/R/nEvents.R	2011-12-12 22:31:36 UTC (rev 325)
@@ -1,16 +1,17 @@
 "nEvents" <- function(hr = .6, alpha = .025, beta = .1, ratio = 1, sided = 1, hr0 =  1, n = 0, tbl = FALSE)
-{   c <- sqrt(ratio) / (1 + ratio)
+{   if (sided != 1 && sided != 2) stop("sided must be 1 or 2")
+    c <- sqrt(ratio) / (1 + ratio)
     delta <- -c * (log(hr) - log(hr0))
     if (n[1] == 0)
-    {   n <- (qnorm(1-alpha)+qnorm(1-beta))^2/delta^2
-        if (tbl) n <- cbind(hr = hr, n = ceiling(n), alpha = alpha, beta = beta, 
+    {   n <- (qnorm(1-alpha/sided)+qnorm(1-beta))^2/delta^2
+        if (tbl) n <- cbind(hr = hr, n = ceiling(n), alpha = alpha, sided=sided, beta = beta, 
                             Power = 1-beta, delta = delta, ratio = ratio, 
                             hr0 = hr0, se = 1/c/sqrt(ceiling(n)))
         return(n)
     }
     else
-    {   pwr <- pnorm(-(qnorm(1-alpha)-sqrt(n) * delta))
-        if (tbl) pwr <- cbind(hr = hr, n = n, alpha = alpha, beta = 1-pwr,
+    {   pwr <- pnorm(-(qnorm(1-alpha/sided)-sqrt(n) * delta))
+        if (tbl) pwr <- cbind(hr = hr, n = n, alpha = alpha, sided=sided, beta = 1-pwr,
                             Power = pwr, delta = delta, ratio = ratio,
                             hr0 = hr0, se = sqrt(1/n)/c)
         return(pwr)



More information about the Gsdesign-commits mailing list