Simplified R-code [R for BE/BA]

posted by Helmut Homepage – Vienna, Austria, 2018-02-26 15:46 (1335 d 11:31 ago) – Posting: # 18468
Views: 11,669

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.

Dif-tor heh smusma 🖖
Helmut Schütz
[image]

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

Complete thread:

Activity
 Admin contact
21,753 posts in 4,548 threads, 1,544 registered users;
online 3 (0 registered, 3 guests [including 3 identified bots]).
Forum time: Sunday 04:18 CEST (Europe/Vienna)

They were “so intent of making everything numerical”
that they frequently missed seeing
what was there to be seen.    Barbara McClintock

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