APFlores
☆    

Philippines,
2014-06-23 10:14
(3962 d 13:49 ago)

Posting: # 13119
Views: 7,929
 

 Sequential Design CDF [Power / Sample Size]

Hi! I'm working on an Excel project that would calculate Power for a sequential BE, based on the journal from Potvin, et al. Unfortunately, I couldn't exactly replicate the calculation of Power at stage 1, as the =NORMSDIST(x) function seemed to be incorrect for this purpose. If anyone could give me the equation for the cumulative dist. function for student's t-dist (given x and DF), I will appreciate it very much.

Kind regards,
Aflores
Helmut
★★★
avatar
Homepage
Vienna, Austria,
2014-06-23 16:08
(3962 d 07:54 ago)

@ APFlores
Posting: # 13126
Views: 7,157
 

 Avoid Excel!

Hi Aflores,

❝ I'm working on an Excel project that would calculate Power for a sequential BE, based on the journal from Potvin, et al. […] the =NORMSDIST(x) function seemed to be incorrect for this purpose.


Avoid Excel! BTW, you are not interested in the standard normal distribution – the function you are looking for is TINV(p, df). Potvin et al. claim in their paper to have used the method of Hauschke et al. (1992).1 Note that this is only
  • an approximation (by the shifted central t-distribution)
    • of an approximation (by the noncentral t-distribution)
      • of the exact method (Owen’s Q-function).
I would not use it whenever possible. See what we get in the first stage of Potvin’s Example 2:

      method       % power 
───────────────────────────
shifted central t   50.49  
noncentral t        52.16  
exact               52.51  
───────────────────────────


I recommend to use the freeware R / package PowerTOST … instead of recreating the wheel in a lousy software.

If you are interested in setting up your own simulations (let’s say the T/R-ratio, target power, or accep­t­ance range are not covered in one of the publications) maybe you are interested in this thread. Note that the convergence of empiric α (i.e., simulating at T/R 1.25) is slow. You need 106 simulations to get a stable estimate. Sim’s of empiric power (i.e., simulating at the expected T/R) con­verge faster; 105 sim’s are sufficient. Results obtained by Power2Stage / function Power.2stage generally agree2 with results reported by Potvin et al. (the few differences might be due to different seeds of the pseudo-random number generator).

n1  CV%    a      b      c      n1  CV%    a      b      c   
─────────────────────────────────────────────────────────────
12   10  0.0297 0.0294 0.0294   12   60  0.0297 0.0299 0.0299
24   10  0.0294 0.0292 0.0292   24   60  0.0307 0.0308 0.0309
36   10  0.0294 0.0293 0.0293   36   60  0.0333 0.0332 0.0332
48   10  0.0292 0.0293 0.0293   48   60  0.0399 0.0399 0.0399
60   10  0.0292 0.0293 0.0293   60   60  0.0466 0.0466 0.0466
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
12   20  0.0463 0.0463 0.0463   12   70  0.0294 0.0293 0.0293
24   20  0.0320 0.0315 0.0315   24   70  0.0299 0.0305 0.0305
36   20  0.0294 0.0294 0.0294   36   70  0.0306 0.0305 0.0305
48   20  0.0292 0.0293 0.0293   48   70  0.0328 0.0325 0.0325
60   20  0.0297 0.0293 0.0293   60   70  0.0381 0.0379 0.0378
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
12   30  0.0437 0.0438 0.0437   12   80  0.0292 0.0293 0.0293
24   30  0.0475 0.0473 0.0475   24   80  0.0298 0.0300 0.0300
36   30  0.0397 0.0396 0.0396   36   80  0.0303 0.0300 0.0300
48   30  0.0324 0.0320 0.0321   48   80  0.0303 0.0300 0.0300
60   40  0.0296 0.0295 0.0295   60   80  0.0318 0.0319 0.0318
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
12   40  0.0344 0.0345 0.0342   12   90  0.0289 0.0291 0.0291
24   40  0.0433 0.0433 0.0431   24   90  0.0298 0.0301 0.0301
36   40  0.0485 0.0484 0.0486   36   90  0.0296 0.0298 0.0298
48   40  0.0458 0.0454 0.0456   48   90  0.0297 0.0299 0.0299
60   40  0.0409 0.0405 0.0406   60   90  0.0300 0.0302 0.0302
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
12   50  0.0309 0.0310 0.0311   12  100  0.0291 0.0290 0.0289
24   50  0.0338 0.0336 0.0336   24  100  0.0298 0.0299 0.0299
36   50  0.0420 0.0418 0.0418   36  100  0.0298 0.0297 0.0297
48   50  0.0484 0.0481 0.0483   48  100  0.0297 0.0297 0.0297
60   50  0.0483 0.0478 0.0478   60  100  0.0301 0.0296 0.0296
─────────────────────────────────────────────────────────────


In simulations with Power.2stage I suggest method="nct". Results are pretty close to the exact ones, but the code runs much faster. On the other hand the boost in speed by method="shifted" is negligible. The gain in accuracy by method="exact" is not worth the efforts. Comparison on my machine of “Method B”, n1 12, CV 20%; 106 sim’s each:
Method     alpha   runtime (min)
────────────────────────────────
shifted  0.046343     1.35      
nct      0.046262     1.50      
exact    0.046053    15.00      
────────────────────────────────


Good luck and happy coding!


  1. Hauschke D, Steinijans VW, Diletti E, Burke M. Sample Size Determination for Bioequivalence Assessment Using a Multiplicative Model. J Pharmacokin Biopharm. 1992;20(5):557–61.
  2. Empiric type I error for “Method B”, 106 sim’s each. Results obtained by Power2Stage (function Power.2stage) which are outside the 95% confidence interval of Potvin’s results (i.e., are sig­ni­fi­cantly different) are formatted in red.
    a: Potvin et al.
    b: Power2Stage v0.1-1; noncentral t
    c: Power2Stage v0.1-2 (experimental – not on CRAN yet); shifted t
    To calculate the 95% CI of a given value use this code (example 0.0297):
    x <- 0.0297
    cat(x, as.numeric(binom.test(x*1e6, 1e6, alternative='two.sided')$conf.int), "\n")

    which gives:
    0.0297 0.02936814 0.03003459

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
APFlores
☆    

Philippines,
2014-06-24 06:40
(3961 d 17:22 ago)

@ Helmut
Posting: # 13131
Views: 6,910
 

 Avoid Excel!

Dear Helmut,

Thanks sir for your immediate response :-)... I guess there's a lot of coding I still need to learn.

BTW, great site!
ElMaestro
★★★

Denmark,
2014-06-24 11:59
(3961 d 12:03 ago)

@ APFlores
Posting: # 13132
Views: 6,924
 

 Sequential Design CDF

Hi APFlores,


❝ (...) If anyone could give me the equation for the cumulative dist. function for student's t-dist (given x and DF), I will appreciate it very much.


further to Helmut's suggestion and relating to the TINV function which you can use to find critical values:
If I recall correctly in Excel you have to specify the probability as 0.1 rather than 0.05 as you would do with certain other stats programs. It has to do with the number of tails considered.

Pass or fail!
ElMaestro
APFlores
☆    

Philippines,
2014-06-25 05:03
(3960 d 19:00 ago)

@ ElMaestro
Posting: # 13139
Views: 6,874
 

 Sequential Design CDF

Dear ElMaestro,

Thank you for your input! Since I'm still a long way from learning R coding, I was able to find the correct Excel function Ft(x,DF) from an add-in from EasyfitXL, which is the =StudentCdf. With this I was finally able to replicate Potvin's Example#2 Method B. Optimal n was achieved by tabulating 20 incrementing n's, and using a lookup function to find the lowest >80% power. I admit this method is crude, but for our current purpose, it will probably do.

Best regards,

Abel.
Helmut
★★★
avatar
Homepage
Vienna, Austria,
2014-06-25 15:58
(3960 d 08:04 ago)

@ APFlores
Posting: # 13143
Views: 6,915
 

 R is not that complicated…

Hi Abel,

❝ Since I'm still a long way from learning R coding,…


It is not that complicated as it seems. See this post about downloading/installation. In many cases you have to use just one line of code. In the following Potvin’s Example 2; both for Methods B and C. From the ANOVA/GLM you get an MSE of 0.0326336.
If the software you are using doesn’t give you the CVintra (18.2%) in the output, you can type mse2CV(0.0326336) and will get 0.1821316.
  • Method B
    • Estimate power based on the adjusted α (0.0294), assumed T/R-ratio (0.95), ob­serv­ed CV (18.2…%), and stage 1 sample size (12):

      power.TOST(alpha=0.0294, theta0=0.95, CV=0.182132, n=12, method="exact")
      You will get:
      [1] 0.5251476 (i.e., 52.51% power)
      For method="nct" 0.5215817 and method="shifted" 0.504907, though I would not recommend it. As Detlew notes in the documentation:
      Of course it is highly recommended to use the default method="exact" :-).
      There is no reason beside testing and comparative purposes to use an approximation if the exact method is available.

      Since we are not BE in the first stage and power <80% we will initiate the second stage.

    • Estimate the total sample size based on the adjusted α (0.0294), power (80%), assumed T/R-ratio (0.95), and observed CV (18.2…%):

      sampleN.TOST(alpha=0.0294, targetpower=0.8, theta0=0.95, CV=0.182132, method="exact")
      You will get:
      +++++++++++ Equivalence test - TOST +++++++++++
                  Sample size estimation
      -----------------------------------------------
      Study design:  2x2 crossover
      log-transformed data (multiplicative model)

      alpha = 0.0294, target power = 0.8
      BE margins        = 0.8 ... 1.25
      Null (true) ratio = 0.95,  CV = 0.182132

      Sample size (total)
       n     power
      20   0.829160

      Since we have performed the first stage in 12 subjects, the second stage should be performed in 20 – 12 = 8 subjects.

  • Method C
    • Similar to Method B, but α 0.05:
      power.TOST(alpha=0.05, theta0=0.95, CV=0.182132, n=12, method="exact")
      Power 66.47 < 80%; initiate the second stage.
    • Since in the pooled analysis of both methods the adjusted α is 0.0294, we use the same code like in Method B.
You need just two lines of R-code; one for the power calculation and one for the sample size estimation. :-D
For the complete stuff see this presentation. BTW, Potvin et al. aimed at 80% power for the entire frame­work; in many cases power is higher. Slide 9 shows that for Method B the expected power for 20 subjects and CV 18% is 88.73%. Therefore, you shouldn’t be too worried about drop-outs compromising power.
If you want to simulate CV 18.2…%:

library(Power2Stage)
power.2stage(method="B", n1=12, GMR=0.95, CV=0.182132)

You will get:

Method B: alpha (s1/s2)= 0.0294 0.0294
Futility criterion Nmax= Inf
CV= 0.182132; n(stage 1)= 12; GMR= 0.95
BE margins = 0.8 ... 1.25
GMR= 0.95 and mse of stage 1 in sample size est. used

1e+05 sims at theta0= 0.95 (p(BE)='power').
p(BE)   = 0.85234
p(BE) s1= 0.52484
pct studies in stage 2= 44.1%

Distribution of n(total)
- mean (range)= 17.3 (12 ... 68)
- percentiles
 5% 50% 95%
 12  12  34

Took four seconds on my machine…

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
APFlores
☆    

Philippines,
2014-06-26 10:38
(3959 d 13:24 ago)

@ Helmut
Posting: # 13148
Views: 6,805
 

 R is not that complicated…

Hi Helmut,

Good day! Already installed R in my computer. As for PowerTOST, I still need to update my Winzip in order to extract the files.

Right now, I'm looking at threads on sample size estimates (n1) for sequential design -- seems that there are a lot of discussions in this area that I still need to read before I post another question ;-)

Thanks again and more power (pun intended)!

Abel
yjlee168
★★★
avatar
Homepage
Kaohsiung, Taiwan,
2014-06-26 12:36
(3959 d 11:26 ago)

@ APFlores
Posting: # 13149
Views: 6,883
 

 no need Winzip to install any R package

Hi Abel,

I don't think that you need Winzip to install any R package. After installing R, open R console and type install.packages("Power2Stage") and then select CRAN mirror that is close to your from pop-up list to install Power2Stage. Done! And then type library(Power2Stage) to load the package first. Next follow Helmut's codes to run it. Not need to know how to do coding stuffs in R too, if you just want to run Power2Stage. If you install Power2Stage this way, it will also install PowerTOST simultaneously for you.

If you prefer downloading Power2Stage.zip first from CRAN mirror site; you can open R console and click Packages on the top menu and select Install package(s) from local zip files... and then find your Power2Stage.zip. It will install Power2Stage too. IMHO, I don't recommend this way because it will not install dependent package (if any) simultaneously. If it is the case, you will need to install these dependent packages manually. AFAIK, Power2Stage requires PowerTOST. That means you have to install PowerTOST manually if you have not installed it yet.

❝ ... Already installed R in my computer. As for PowerTOST, I still need to update my Winzip in order to extract the files.


All the best,
-- Yung-jin Lee
bear v2.9.2:- created by Hsin-ya Lee & Yung-jin Lee
Kaohsiung, Taiwan https://www.pkpd168.com/bear
Download link (updated) -> here
APFlores
☆    

Philippines,
2014-06-27 10:58
(3958 d 13:04 ago)

@ yjlee168
Posting: # 13153
Views: 6,754
 

 no need Winzip to install any R package

Hi yjlee168,

Thanks for the info. I'll be doing your tip later this evening. Best regards.

Abel
UA Flag
Activity
 Admin contact
23,424 posts in 4,927 threads, 1,673 registered users;
95 visitors (0 registered, 95 guests [including 1 identified bots]).
Forum time: 00:03 CEST (Europe/Vienna)

There are two possible outcomes: if the result confirms the
hypothesis, then you’ve made a measurement. If the result is
contrary to the hypothesis, then you’ve made a discovery.    Enrico Fermi

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