How to create table of sample sizes / powers [Power / Sample Size]

posted by Helmut Homepage – Vienna, Austria, 2017-07-20 17:18 (2767 d 18:26 ago) – Posting: # 17580
Views: 8,783

Hi BE-proff,

try this (for 80 and 90% target power):

CV     <- 0.26
theta0 <- seq(0.85, 1.20, 0.05)
thetas <- length(theta0)
target <- c(0.8, 0.9)
result <- data.frame(CV=rep(CV, thetas), GMR=sprintf("%.4f", theta0),
                     n1=rep(NA, thetas), pwr1=rep(NA, thetas),
                     n2=rep(NA, thetas), pwr2=rep(NA, thetas))
names(result)[3:6] <- rep(c("n", "power"), 2)
for (j in seq_along(theta0)) {
  x1 <- sampleN.TOST(CV=CV, theta0=theta0[j],
                     targetpower=target[1], print=F)
  x2 <- sampleN.TOST(CV=CV, theta0=theta0[j],
                     targetpower=target[2], print=F)
  result[j, 3] <- x1[["Sample size"]]
  result[j, 4] <- sprintf("%.2f%%", 100*x1[["Achieved power"]])
  result[j, 5] <- x2[["Sample size"]]
  result[j, 6] <- sprintf("%.2f%%", 100*x2[["Achieved power"]])
}
print(result, row.names=FALSE)

Should give:

   CV    GMR   n  power   n  power
 0.26 0.8500 222 80.09% 308 90.15%
 0.26 0.9000  60 80.18%  84 90.57%
 0.26 0.9500  30 80.63%  40 90.31%
 0.26 1.0000  24 80.03%  30 90.12%
 0.26 1.0500  30 81.51%  40 91.01%
 0.26 1.1000  52 80.76%  70 90.02%
 0.26 1.1500 118 80.09% 164 90.23%
 0.26 1.2000 488 80.09% 674 90.01%

Note that power curves are not symmetrical around 100%. If you assume a ∆ of 10% (without knowing whether T will be lower or higher than R), work with 0.90. The sample size will cover 1.10 as well.
Try this:

theta0 <- seq(0.85, 1, 0.05)
theta0 <- unique(c(theta0, rev(1/theta0)))
thetas <- length(theta0)

Should give:

   CV    GMR   n  power   n  power
 0.26 0.8500 222 80.09% 308 90.15%
 0.26 0.9000  60 80.18%  84 90.57%
 0.26 0.9500  30 80.63%  40 90.31%
 0.26 1.0000  24 80.03%  30 90.12%
 0.26 1.0526  30 80.63%  40 90.31%
 0.26 1.1111  60 80.18%  84 90.57%
 0.26 1.1765 222 80.09% 308 90.15%

Do you get the idea?

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
23,381 posts in 4,914 threads, 1,662 registered users;
39 visitors (1 registered, 38 guests [including 14 identified bots]).
Forum time: 10:45 CET (Europe/Vienna)

Science is built up with facts, as a house is with stones.
But a collection of facts is no more a science
than a heap of stones is a house.    Henri Poincaré

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5