Ben ★ 2011-11-14 20:16 (4914 d 21:55 ago) Posting: # 7672 Views: 9,954 |
|
Dear all, in clinical development one often performs trials in order to estimate possible effects instead of testing whether there is a significant effect or not. Therefore one is more interested in the confidence interval itself and requires this to be no larger than a pre-specified width 2w. The question what sample size should be used boils down to solving w >= qantile*sqrt(Var(S)) iteratively, where Var(S) depends on n. As the focus is on the confidence interval it is however recommended to assure that with a certain probability 1-gamma (the so called coverage probability) the half-width of the CI is actually not greater than w, see Kupper and Hafner in their 1989 article "How Appropriate Are Popular Sample Size Formulas?" (The American Statistician, vol 43, pp 101-105). They consider the one-sample and the two-sample case. nQuery also has a way to calculate the desired sample size, but again only for a two group design (module MTG) and a 2x2 design (module MOC) (actually nQuery calls it paired design). So I tried to implement the procedure, extending it a little bit to allow for more possible designs (as in the function CVfromCI from the R package PowerTOST). require(PowerTOST) I played a little bit and some issues/questions came up.
Best, Ben |
d_labes ★★★ Berlin, Germany, 2011-11-16 10:40 (4913 d 07:32 ago) @ Ben Posting: # 7675 Views: 8,788 |
|
Dear Ben, I must confess that I haven't dealt with sample size planning to a given precision of the confidence interval up to now. Within that forum this type of sample size planning is a little bit Off Topic. All sample size planning within BE studies is usually done via power of the underlying two one-sided t-tests (TOST) for the bioequivalence decision. That's the reason I had written the R package PowerTOST. Cool that you have discovered some hidden helper functions and tried to reuse them ![]() So in the end I can't say something specific to your problems without delving deeper into the mathematical apparatus of sample size planning with the aim of attaining a given precision. For that I haven't enough spare time in the moment. Only some remarks and tips:
— Regards, Detlew |
Ben ★ 2011-11-18 17:57 (4911 d 00:15 ago) @ d_labes Posting: # 7682 Views: 8,726 |
|
Thanks for your reply! Sorry, I didn't know that this is off topic, because I assumed this falls into the category "bioavailability". Yes, of course I am questioning my program. But on the other hand I tried to check as good as possible. In the article from Kupper and Hafner there are tables (unfortunately for the one sample and the two sample case only) which show the final sample size given an initial sample size. I checked my program according to this table - it works out fine. Also, I checked my results via FARTSSIE now (thanks for the link). In this spreadsheet only the case without coverage probability is considered. These values coincide with the "initial sample size" from my program (the first while loop) - at least for the test cases I used. nQuery also has a module for calculating such a sample size (i.e. without coverage probability) but here nQuery uses z-quantiles (I again get the same results by changing the t-quantiles to z-quantiles). Some more rough results (incorporating the coverage probability)
❝ I'm not quite sure if the design constants are specific for the TOST procedure and make sense for your problem. Check the underlying formulas for each design you will implement with respect to these constants. Hope this helps. Me either, but the same argument applies to CVfromCI? CVfromCI isn't TOST specific, is it? I have to learn more about the design constant, and I will check out the references you gave me. Thanks again for all the comments. Best regards, Ben |
Ben ★ 2011-11-21 20:13 (4907 d 21:59 ago) @ Ben Posting: # 7694 Views: 8,577 |
|
Dear all, I started from scratch. The only thing that's important is the requirement P(S·(bk/n)-1/2·tdf, 1-α/2 ≤ ω) ≥ 1-γ, where df is the appropriate degrees of freedom of the considered design, S the estimate of the standard deviation and bk the design constant. We want the smallest integer so that the above inequality holds. In the article they derive inequalities that are easier to handle than the probability. Since nowadays evaluating P is no problem (fast computers) we can directly go with the above relation. (The reason why I got different results was that (i) one derived inequality was conservative and (ii) the initial sample size was based on the z-quantile and not on the t-quantile.) Now the above inequality can be equivalently stated as P(df·S2/σ² ≤ (ω/σ)2·df·(bk/n)1/F1, df, 1-α) ≥ 1-γ Then (df·S²)/σ² is chi squared distributed with df degrees of freedom (is that always true for every considered design?) and we can set up the following code to get the desired sample size:
require(PowerTOST) Again, I will look into the design constant and the correct usage of it more closely but at the moment I don't see a difference to CVfromCI() . For the parallel and the 2x2 crossover design the results are the same as those from nQuery (sometimes it differs, but only +-1, probably due to rounding/higher precision).Comments are highly appreciated. Best regards, Ben |
d_labes ★★★ Berlin, Germany, 2011-11-22 16:37 (4907 d 01:35 ago) @ Ben Posting: # 7699 Views: 8,575 |
|
Dear Ben, ❝ ... at the moment I don't see a difference to CVfromCI. Correct ![]() ❝ For the parallel and the 2x2 crossover design the results are the same as those from nQuery (sometimes it differs, but only +-1, probably due to rounding/higher precision). Congratulation ![]() BTW: Jerry Hinze's PASS also has a module "Confidence Intervals for Paired Means with Tolerance Probability" with df=n-1. My checks with your code against the tables in the Joulious book show total agreement for the parallel group design as well as for the 2x2 crossover. Here some minor code suggestions: ss_ci <- function(w, sigma, design="2x2", alpha=0.1, gamma=0.05, debug=FALSE) — Regards, Detlew |
Ben ★ 2011-11-23 22:12 (4905 d 20:00 ago) @ d_labes Posting: # 7704 Views: 8,512 |
|
Thank you very much for your effort and help! ❝ ... I strongly argue that the differences are more probably due to the different number of degrees of freedom, namely df=n-1 in the so-called 'paired' design. You (having access to nQuery) can test it with my code suggestions below. You're absolutely right! I didn't check very thoroughly but so far it seems that exactly these df are being used (this indeed makes sense as the CI is for difference in "paired means") ❝ Here some minor code suggestions: ... You put in some nice features (starting value of n and the step size), awesome. One suggestion/question from myself: should it be n <- step*ceiling(n/step) instead of n <- step*trunc(n/step) ? Otherwise we will get an error using e.g. w=0.3, sigma=0.2, design="2x2".Also, one could think of including n=NULL or something like that as input parameter and then return the precision if a sample size is given, that is,
if (is.null(n)) { The values of w coincide with those of nQuery (using "paired"). Best regards |
Ben ★ 2011-11-25 18:28 (4903 d 23:43 ago) @ Ben Posting: # 7726 Views: 8,461 |
|
❝ My checks with your code against the tables in the Joulious book show total agreement for the parallel group design as well as for the 2x2 crossover. I also checked against these tables, but I do not always get the same result as in the table. For example, using
w=0.5*0.2, sigma=0.2, design="2x2", alpha=0.05, gamma=0.05 (i.e. delta=0.5) I get 46. Julious has 45. I do get the same results if the design is "paired", but Julious obviously is talking about cross-over (df = n-2)?! Sorry, that's just because we increase n by step. 45 is the result if we increase by 1. Edit: Added from a follow-up post; you may edit your post within 24 hours. [Helmut] |
d_labes ★★★ Berlin, Germany, 2011-12-15 10:28 (4884 d 07:43 ago) @ Ben Posting: # 7782 Views: 8,182 |
|
Dear Ben, my above warning about using undocumented, internal functions now comes into effect. To release a new version of PowerTOST I got stuck with a new technical demand for R-packages from R version 2.14.0 on, the so-called NAMESPACE (whatever this really is doesn't fit in my small brain). The consequence of my limited understanding of that matter is that hidden functions from package PowerTOST are no longer callable from outside that simple. If I understood correctly you can try the syntax PowerTOST:::.design.no(design) Using such a syntax it is even not necessary to load the package via library() or require() ![]() Cough ![]() — Regards, Detlew |
Ben ★ 2011-12-16 20:06 (4882 d 22:06 ago) @ d_labes Posting: # 7785 Views: 8,181 |
|
Thanks for the hint, I'll keep this in mind! |