## Initial sample size guess for the Potvin methods [Two-Stage / GS Designs]

Hi all,

just wanted to share a little algo for the initial sample size guess for the Potvin methods.

This is an area where speed gains are possible. A good initial sample size guess can eliminate quite some computation time. As I never got Zhang's method I played a little around with an entirely empirical idea.

My idea is that at least the upper part of a curve of power as function of sample size can be modeled as a kind of sigmoid function. I googled around to find a few expressions for such curves. The logistic function is one such. We can write the approximation something like:

where N is the sample size.

If we have two estimates of power p1, p2 at sample sizes nps1 and nps2 (I use number of subjects per sequence, abbreviated as nps), then we can determine the constants:

We can then solve for the desired power Pwr.T:

- and this should of course converted to integer.

It turns out in my application to work really, really well.

The "only" issue is if the initial nps1 and nps2 are chosen poorly; p1 needs to be "not too close" to zero and p2 needs to be "not too close" to 1. But that's it.

My current implementation is this:

Works well for me for assumed GMR's close to 1 (such as 0.95) and I am sure if anyone cares to fiddle with it it can be improved much, much further to work well in "all" scenarios. Play around with the constants in red to get the optimization that works for you.

just wanted to share a little algo for the initial sample size guess for the Potvin methods.

This is an area where speed gains are possible. A good initial sample size guess can eliminate quite some computation time. As I never got Zhang's method I played a little around with an entirely empirical idea.

My idea is that at least the upper part of a curve of power as function of sample size can be modeled as a kind of sigmoid function. I googled around to find a few expressions for such curves. The logistic function is one such. We can write the approximation something like:

`Power=1/(1+exp(-k(N-x0)))`

where N is the sample size.

If we have two estimates of power p1, p2 at sample sizes nps1 and nps2 (I use number of subjects per sequence, abbreviated as nps), then we can determine the constants:

```
a2=log(1/p2 - 1)
```

a1=log(1/p1 - 1)

x0=(a2*nps1-a1*nps2)/(a2-a1)

k=a1/(x0-nps1)

We can then solve for the desired power Pwr.T:

`nps= x0+ (log(1/Pwr.T -1) / (-k))`

- and this should of course converted to integer.

It turns out in my application to work really, really well.

The "only" issue is if the initial nps1 and nps2 are chosen poorly; p1 needs to be "not too close" to zero and p2 needs to be "not too close" to 1. But that's it.

My current implementation is this:

`GetStartNps.X3=function(GMR, CV, Pwr.T)`

{

nps1=6

p1=Power.calc(nps1, GMR, CV, Is.St2=1) ##equation in Potvin et al.

for (i in 1:3)

if (p1<0.1) { nps1=4*nps1;p1=Power.calc(nps1, GMR, CV, Is.St2=1);}

nps2=20*nps1

p2=Power.calc(nps2, GMR, CV, Is.St2=1)

f=2.4

while(p2>0.99) { nps2=floor(nps2/f);p2=Power.calc(nps2, GMR, CV, Is.St2=1);}

a2=log(1/p2 - 1)

a1=log(1/p1 - 1)

x0=(a2*nps1-a1*nps2)/(a2-a1)

k=a1/(x0-nps1)

Nps=floor( x0+ (log(1/Pwr.T -1) / (-k)) )

if (Nps<6) Nps=6

return(Nps)

}

Works well for me for assumed GMR's close to 1 (such as 0.95) and I am sure if anyone cares to fiddle with it it can be improved much, much further to work well in "all" scenarios. Play around with the constants in red to get the optimization that works for you.

—

I could be wrong, but…

Best regards,

ElMaestro

- since June 2017 having an affair with the bootstrap.

I could be wrong, but…

Best regards,

ElMaestro

- since June 2017 having an affair with the bootstrap.

### Complete thread:

- Initial sample size guess for the Potvin methods - ElMaestro, 2017-08-19 15:04 [Two-Stage / GS Designs]
- Initial sample size guess for the Potvin methods - Helmut, 2017-08-19 16:06
- Initial sample size guess for the Potvin methods - ElMaestro, 2017-08-19 16:14
- Initial sample size guess for the Potvin methods - Helmut, 2017-08-19 17:12
- Initial sample size guess for the Potvin methods - ElMaestro, 2017-08-19 17:17
- Confuse-a-Cat - Helmut, 2017-08-19 17:33
- Confuse-a-Cat - ElMaestro, 2017-08-19 17:56

- Confuse-a-Cat - Helmut, 2017-08-19 17:33

- Initial sample size guess for the Potvin methods - ElMaestro, 2017-08-19 17:17
- loop ↔ vectorized ↔ direct - Helmut, 2017-08-20 14:40
- loop ↔ vectorized ↔ direct - ElMaestro, 2017-08-20 15:22
- loop ↔ vectorized ↔ direct - Helmut, 2017-08-20 16:23
- loop ↔ vectorized ↔ direct - ElMaestro, 2017-08-20 17:22

- loop ↔ vectorized ↔ direct - Helmut, 2017-08-20 16:23

- loop ↔ vectorized ↔ direct - ElMaestro, 2017-08-20 15:22

- Initial sample size guess for the Potvin methods - Helmut, 2017-08-19 17:12

- Initial sample size guess for the Potvin methods - ElMaestro, 2017-08-19 16:14
- The n ext crackpot iteration - ElMaestro, 2017-08-19 20:04
- The n ext crackpot iteration - Helmut, 2017-08-20 02:20

- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 14:35
- The ultimate crackpot iteration! - Helmut, 2017-08-20 15:11
- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 15:28
- The ultimate crackpot iteration! - Helmut, 2017-08-20 16:06
- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 16:15
- The ultimate crackpot iteration! - Helmut, 2017-08-20 18:58
- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 19:32
- Suggested code - ElMaestro, 2017-08-21 18:13
- Nitpicker! - Helmut, 2017-08-22 13:33
- Nitpicker! - ElMaestro, 2017-08-22 17:27
- Nitpicker! - Helmut, 2017-08-22 17:49
- Nitpicker! - ElMaestro, 2017-08-22 17:59
- Nitpicker! - Helmut, 2017-08-22 19:15
- Benchmark code - ElMaestro, 2017-08-22 22:29
- Benchmark code - Helmut, 2017-08-23 01:48

- Benchmark code - ElMaestro, 2017-08-22 22:29

- Nitpicker! - Helmut, 2017-08-22 19:15

- Nitpicker! - ElMaestro, 2017-08-22 17:59

- Nitpicker! - Helmut, 2017-08-22 17:49

- Nitpicker! - ElMaestro, 2017-08-22 17:27

- Nitpicker! - Helmut, 2017-08-22 13:33

- Suggested code - ElMaestro, 2017-08-21 18:13

- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 19:32

- The ultimate crackpot iteration! - Helmut, 2017-08-20 18:58

- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 16:15

- The ultimate crackpot iteration! - Helmut, 2017-08-20 16:06

- The ultimate crackpot iteration! - ElMaestro, 2017-08-20 15:28

- The ultimate crackpot iteration! - Helmut, 2017-08-20 15:11

- Initial sample size guess for the Potvin methods - Helmut, 2017-08-19 16:06