n iteratively from power [Power / Sample Size]

posted by Helmut Homepage – Vienna, Austria, 2021-10-24 12:54 (939 d 23:43 ago) – Posting: # 22655
Views: 3,086

Hi Imph,

❝ Thank you so much. Your response has been of great help.


Welcome.

❝ – By consulting Dileti's paper, I noticed that there is no formula for the calculation of the number of subjects. Is there a way or a reference to get the formula please.


You can only calculate power for a given sample size, i.e., you start with an assumption and then increase (or decrease) n to obtain at least the target power. See there for the details.

Step by step:

library(PowerTOST)
CV     <- 0.25
theta0 <- 0.95
target <- 0.80
n      <- 12                    # minimum acc. to the GLs
power  <- power.TOST(CV = CV, theta0 = theta0, n = n)
iter   <- 1
res    <- data.frame(iter = iter, n = n, power = power)
if (res$power[iter] < target) { # upwards
  repeat {
    power <- power.TOST(CV = CV, theta0 = theta0, n = n)
    res[iter, ] <- c(iter, n, power)
    if (power >= target) {
      break
    } else {
      iter <- iter + 1
      n    <- n + 2
    }
  }
} else {                        # downwards
  repeat {
    power <- power.TOST(CV = CV, theta0 = theta0, n = n)
    res[iter, ] <- c(iter, n, power)
    if (power < target) {
      res <- res[-nrow(res), ]
      break
    } else {
      iter <- iter + 1
      n    <- n - 2
    }
  }
}
print(res, row.names = FALSE)

 iter  n     power
    1 12 0.3137351
    2 14 0.4141013
    3 16 0.5041795
    4 18 0.5801284
    5 20 0.6430574
    6 22 0.6953401
    7 24 0.7391155
    8 26 0.7760553
    9 28 0.8074395


In PowerTOST’s sample size functions you can show the iterations by setting the argument details to TRUE (by default only the final result is shown):

sampleN.TOST(CV = 0.25, theta0 = 0.95, targetpower = 0.80, details = TRUE)

+++++++++++ Equivalence test - TOST +++++++++++
            Sample size estimation
-----------------------------------------------
Study design: 2x2 crossover
Design characteristics:
df = n-2, design const. = 2, step = 2

log-transformed data (multiplicative model)

alpha = 0.05, target power = 0.8
BE margins = 0.8 ... 1.25
True ratio = 0.95,  CV = 0.25

Sample size search (ntotal)
 n     power
26   0.776055
28   0.807439

Exact power calculation with
Owen's Q functions.


❝ – […] in the calculation of the degrees of freedom, for example (2n-2), where "n" has to be estimated. I would like to know on what basis this "n" is estimated.


See above.

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,034 posts in 4,835 threads, 1,647 registered users;
33 visitors (0 registered, 33 guests [including 8 identified bots]).
Forum time: 12:37 CEST (Europe/Vienna)

Give me a fruitful error any time, full of seeds, bursting with its own corrections.
You can keep your sterile truth for yourself.    Vilfredo Pareto

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