Simplified R-code [R for BE/BA]

posted by Helmut Homepage – Vienna, Austria, 2018-02-26 15:46 (1339 d 05:06 ago) – Posting: # 18468
Views: 11,693

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,759 posts in 4,550 threads, 1,545 registered users;
online 11 (0 registered, 11 guests [including 5 identified bots]).
Forum time: Wednesday 21:53 CEST (Europe/Vienna)

There ain’t no rules around here!
We’re trying to accomplish something!    Thomas Alva Edison

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