Simplified R-code [R for BE/BA]

posted by Helmut Homepage – Vienna, Austria, 2018-02-26 15:46  – Posting: # 18468
Views: 5,076

Dear Detlew & Ana Cristina,

» Gender and subject are an entity (at least in almost all cases except transgender subjects).
» Thus taking e.g. 8 males and 8 females and randomize them to the sequence groups is enough IMHO.

Good point!

@Ana Cristina: Simplified R-code (changes) including the runs test for randomness:

library(randomizeBE)
blocksize <- 8
sex       <- rep(c("F", "M"), each=blocksize)
random    <- RL4(nsubj=2*blocksize, seqs=c("TR", "RT"),
                 blocksize=blocksize, randctrl=TRUE)
random$rl <- cbind(random$rl, sex=sample(sex),
                   "period 1"=paste0(substr(random$rl$sequence, 1, 1), "   "),
                   "period 2"=paste0(substr(random$rl$sequence, 2, 2), "   ")
)
random$rl <- random$rl[, c("subject", "sex", "seqno", "sequence",
                           "period 1", "period 2")]

print(random, sumry=TRUE)


Gives with a random seed on my machine

Randomization table          created: 2018-02-26 15:45:26
(seed: 7849936 blocksize: 8 )

 subject sex seqno sequence period 1 period 2
       1   F     1       TR     T        R   
       2   M     2       RT     R        T   
       3   M     1       TR     T        R   
       4   M     2       RT     R        T   
       5   F     2       RT     R        T   
       6   F     2       RT     R        T   
       7   M     1       TR     T        R   
       8   F     1       TR     T        R   
       9   F     2       RT     R        T   
      10   M     1       TR     T        R   
      11   M     1       TR     T        R   
      12   M     1       TR     T        R   
      13   M     1       TR     T        R   
      14   F     2       RT     R        T   
      15   F     2       RT     R        T   
      16   F     2       RT     R        T   


Summary of randomisation

16 subjects randomized into 2 sequence groups.
Number of subjects in sequence groups:
RT TR
 8  8
Runs test of randomness: p.value=0.6048


Note that if you change the names of columns (like in this post) to Portuguese and/or remove the sequence column, the summary will not work any more.


Edit: Don’t use this code. For an update see this post.

Cheers,
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. ☼
Science Quotes

Complete thread:

Activity
 Mix view
Bioequivalence and Bioavailability Forum |  Admin contact
19,478 posts in 4,133 threads, 1,333 registered users;
online 18 (0 registered, 18 guests [including 8 identified bots]).
Forum time (Europe/Vienna): 04:43 CEST

If you don’t know anything about computers,
just remember that they are machines that do exactly what you tell them
but often surprise you in the result.    Richard Dawkins

The BIOEQUIVALENCE / BIOAVAILABILITY FORUM is hosted by
BEBAC Ing. Helmut Schütz
HTML5