[Gsdesign-commits] r328 - pkg/gsDesign/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Dec 30 13:44:22 CET 2011
Author: keaven
Date: 2011-12-30 13:44:18 +0100 (Fri, 30 Dec 2011)
New Revision: 328
Modified:
pkg/gsDesign/R/nNormal.R
Log:
Replaced nNormal.R
Modified: pkg/gsDesign/R/nNormal.R
===================================================================
--- pkg/gsDesign/R/nNormal.R 2011-12-26 15:03:32 UTC (rev 327)
+++ pkg/gsDesign/R/nNormal.R 2011-12-30 12:44:18 UTC (rev 328)
@@ -1,23 +1,14 @@
# sample size for fixed design with 2-arms, normal endpoint,
# ratio = randomization ratio
-nNormal<-function(delta1=1,sigma=1.7,sigalt=NULL,alpha=.025,beta=.1,ratio=1,delta0=0)
+nNormal<-function(delta1=1,sigma=1.7,sigalt=NULL,alpha=.025,beta=.1,ratio=1,
+ sided=1, n=NULL,delta0=0)
{ xi <- ratio/(1+ratio)
+ if (sided==2) alpha <- alpha/2
if(is.null(sigalt)) sigalt <- sigma
v <- sigalt^2/xi + sigma^2/(1-xi)
theta1 <- (delta1-delta0)/sqrt(v)
- n <- ((qnorm(alpha)+qnorm(beta))/theta1)^2
- n
+ if (is.null(n))
+ return(((qnorm(alpha)+qnorm(beta))/theta1)^2)
+ else
+ return(pnorm(sqrt(n)*theta1-qnorm(1-alpha)))
}
-
-# EXAMPLES
-# equal variances
-n.fix <- nNormal(delta1=.5,sigma=1.1,alpha=.025,beta=.2)
-
-# unequal variances
-
-
-# unequal sample sizes
-
-
-# non-inferiority
-n.fix <- nNormal(delta1=0,delta0=.5,sigma=1.2)
More information about the Gsdesign-commits
mailing list