Simulations 101 [Power / Sample Size]

posted by Helmut Homepage – Vienna, Austria, 2020-05-27 23:06 (919 d 01:46 ago) – Posting: # 21486
Views: 2,265

Dear Detlew!

:clap: Can't :clap: enough!


THX!

❝ One small correction: The graphics under "Sample size for RSABE" is apparent not correct here.


Hhm, why?

library(PowerTOST)
library(magicaxis)
runs  <- 5
nsims <- as.integer(10^(seq(3, 6, 0.1)))
res   <- data.frame(nsims = nsims)
for (k in seq_along(nsims)) {
  for (j in 1:runs) {
    ifelse (j == 1, setseed <- TRUE, setseed <- FALSE)
    res[k, j+1] <- sampleN.RSABE(theta0 = 0.9, CV = 0.7, nsims = nsims[k],
                                 setseed = setseed, design = "2x2x4",
                                 targetpower = 0.9, print = FALSE,
                                 details = FALSE)[["Sample size"]]
  }
}
ylim <- range(res[, 2:(runs+1)], na.rm = TRUE)
dev.new(width = 5, height = 5)
op <- par(no.readonly = TRUE)
par(pty = "s")
plot(res$nsims, res[, 1], type = "n", log = "x", ylim = ylim, axes = FALSE,
     xlab = "Number of simulations", ylab = "Sample size")
grid(); box()
magaxis(1)
magaxis(2, minorn = 2, las = 1)
for (j in 1:runs) {
  ifelse (j == 1,  pch <- 16, pch <- 1)
  points(res$nsims, res[, j+1], pch = pch, col = "blue", cex = 1.15)
}
points(1e5, 48, pch = 16, col = "#00AA00", cex = 1.15) # default
points(1e4, 46, pch = 16, col = "red", cex = 1.15)     # Lászlós
par(op)
print(res, row.names = FALSE)

   nsims V2 V3 V4 V5 V6
    1000 50 48 54 52 50
    1258 50 48 52 50 52
    1584 50 50 52 50 56
    1995 50 48 50 50 50
    2511 48 48 48 48 52
    3162 48 50 50 50 50
    3981 46 48 50 50 48
    5011 46 50 50 50 48
    6309 46 48 48 48 50
    7943 46 50 48 48 50

   10000 46 50 48 50 50
   12589 46 50 48 50 48
   15848 48 48 48 48 48
   19952 48 48 50 50 48
   25118 48 48 50 48 48
   31622 48 48 48 48 48
   39810 48 48 50 48 50
   50118 48 48 48 48 48
   63095 48 48 48 48 48
   79432 48 48 48 48 48

  100000 48 48 48 48 48
  125892 48 48 48 48 48
  158489 48 48 48 48 48
  199526 48 48 48 48 48
  251188 48 48 48 48 48
  316227 48 48 48 48 48
  398107 48 48 48 48 48
  501187 48 48 48 48 48
  630957 48 48 48 48 48
  794328 48 48 48 48 48
 1000000 48 48 48 48 48


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
22,424 posts in 4,694 threads, 1,600 registered users;
21 visitors (2 registered, 19 guests [including 9 identified bots]).
Forum time: 23:52 CET (Europe/Vienna)

The rise of biometry in this 20th century,
like that of geometry in the 3rd century before Christ,
seems to mark out one of the great ages or critical periods
in the advance of the human understanding.    R.A. Fisher

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