randomization [🇷 for BE/BA]
Hi A.C.,
Let us say you have 16 subjects.
8 will be female, 8 will be male. As you enroll them into the study you assign subjects numbers sequentially so that the females are 1..8, and the males are 9..16.
The follwing code will provide a randomizer:
It is a good idea to use a new seed every time and to record the one you are actually using.
Note also that this algo assigns unique subjects numbers to every participant. Then we do not need to worry about Subject%in%Sequence and we are compliant with ICH E6 §1.58 (unique identifier).
Let us say you have 16 subjects.
8 will be female, 8 will be male. As you enroll them into the study you assign subjects numbers sequentially so that the females are 1..8, and the males are 9..16.
The follwing code will provide a randomizer:
## we have N subjects, N is divisible by 4
## N/2 will be males, N/2 will be females
## N/4 will be males in TR
## N/4 will be males in RT
## N/4 will be females in TR
## N/4 will be females in RT
Ana.Cristinas.Randomizer=function(Seed, N)
{
if (N %% 4 != 0) {cat("N not divisible by four.!\n");return("Error.")}
Gender=c(rep("F", N/2), rep("M", N/2))
Subject=c(1:N)
##We need to assign sequences to both genders
##N/4 males are assigned to TR and N/4 to RT
Seqx=c(rep("TR", N/4), rep("RT", N/4))
##Seqx is just an 'unrandomised' block that applies to both genders.
##Now we permute the sequences(=resample without replacement) for M and F
Seq=c(sample(Seqx, replace=F), sample(Seqx, replace=F))
TrtP1=substr(Seq,1,1)
TrtP2=substr(Seq,2,2)
Rslt=data.frame(Subject, Gender, Seq, TrtP1, TrtP2)
return(Rslt)
}
##can be run with e.g.
Ana.Cristinas.Randomizer(12312351, 16)
It is a good idea to use a new seed every time and to record the one you are actually using.
Note also that this algo assigns unique subjects numbers to every participant. Then we do not need to worry about Subject%in%Sequence and we are compliant with ICH E6 §1.58 (unique identifier).

—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- randomization Ana Cristina 2018-02-23 21:33 [🇷 for BE/BA]
- randomizationElMaestro 2018-02-23 22:24
- randomization Ana Cristina 2018-02-24 16:47
- randomization ElMaestro 2018-02-24 17:32
- package randomizeBE for R on steroids Helmut 2018-02-24 17:52
- Randomization of gender d_labes 2018-02-26 11:56
- Simplified R-code Helmut 2018-02-26 15:46
- Simplified R-code Ana Cristina 2018-02-27 13:16
- Updated R-code Helmut 2018-02-27 17:06
- Gender in crossover d_labes 2018-02-28 08:43
- Gender in crossover nobody 2018-02-28 10:14
- Sex in crossover Helmut 2018-02-28 12:42
- Sex in crossover Helmut 2018-02-28 12:27
- OT: Sex / gender d_labes 2018-02-28 14:42
- OT: Sex / gender Helmut 2018-02-28 14:58
- OT: Sex / gender Ana Cristina 2018-03-01 03:16
- OT: Sex / gender Helmut 2018-02-28 14:58
- OT: Sex / gender d_labes 2018-02-28 14:42
- Gender in crossover nobody 2018-02-28 10:14
- Updated R-code Beholder 2020-04-08 12:31
- Gender in crossover d_labes 2018-02-28 08:43
- Updated R-code Helmut 2018-02-27 17:06
- Simplified R-code Ana Cristina 2018-02-27 13:16
- Simplified R-code Helmut 2018-02-26 15:46