Simplified R-code [🇷 for BE/BA]

posted by Helmut Homepage – Vienna, Austria, 2018-02-26 16:46 (2221 d 15:33 ago) – Posting: # 18468
Views: 13,622

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 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

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

Complete thread:

UA Flag
Activity
 Admin contact
22,957 posts in 4,819 threads, 1,641 registered users;
23 visitors (0 registered, 23 guests [including 4 identified bots]).
Forum time: 08:19 CET (Europe/Vienna)

Nothing shows a lack of mathematical education more
than an overly precise calculation.    Carl Friedrich Gauß

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