loop ↔ vectorized ↔ direct [Two-Stage / GS Designs]

posted by ElMaestro  – Belgium?, 2017-08-20 17:22 (1192 d 02:06 ago) – Posting: # 17726
Views: 24,850

Hi Hötzi,

» I don’t understand why you use vectors at all. What ’bout:
»

df <- Nps*2-2
» if (!Is.St2) {
»   q  <- qt(p=1-alpha1, df=df)
» } else {
»   df <- df-1
»   q  <- qt(p=1-alpha2, df=df)
» }



Simple, but I think I aready told you: qt is a computationally very expensive function. If we need "many" qt values then it makes much more sense in terms of computation to cache the well-defined ones.

Within the 1000000 iterations values from qt are needed many times, but each of them have defined ranges of DF's (up to the max number of subjects -3 [or 2:-)]) and alphas (two levels). Thus we make a cache of qt values prior to entering the iteration loop then we can just take a sample from the cache in stead of re-inventing the wheel for every call. Do the population of the arrays once, and rely on them during the iterations or whatever other functions that need them. The speedup can be massive both in R and in C.

I could be wrong, but...

Best regards,
ElMaestro

No, of course you do not need to audit your CRO if it was inspected in 1968 by the agency of Crabongostan.

Complete thread:

Activity
 Admin contact
21,206 posts in 4,425 threads, 1,481 registered users;
online 2 (0 registered, 2 guests [including 2 identified bots]).
Forum time: Tuesday 18:29 CET (Europe/Vienna)

All we know about the world teaches us that the effects of A and B
are always different—in some decimal place—for any A and B.
Thus asking “are the effects different?” is foolish.    John W. Tukey

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