Randomization of Subjects in two arm designs
Shubham Lahoti
September 26, 2024
PatientRandomization.Rmd
Introduction :
In the RCode directory of this example you will find the following R files:
- RandomizationSubjectsUsingUniformDistribution.R
The R function named “RandomizationSubjectsUsingUniformDistribution” in the file randomly allots the subjects on either of two arms using Uniform Distribution.
Steps : 1) We generate a random number from Uniform(0, 1). Save it as u. 2) Let p = Allocation fraction on Control arm and 1 - p = Allocation fraction on treatment arm. 3) If u <= p then allot the subject to Control arm else allot the subject to treatment arm. 4) Make sure that Total sample size = Sample size on control + Sample size on treatment arm.
- RandomizationSubjectsUsingSampleFunctionInR.R
The R function named “RandomizationSubjectsUsingSampleFunctionInR” in the file makes use of Sample() function in R to randomly allot the patients on Control and treatment arm.
Steps:
- Let p = Allocation fraction on Control arm and 1 - p = Allocation fraction on treatment arm.
- Compute Expected Sample size (rounded) for Control and treatment arms using Allocation Fraction and Total sample size.
- Randomly allot the indices to Control and treatment arms using sample() functionality available in R.
- Create a vector of zeroes of size = NumSub (Number of subjects) and then replace the zeroes by 1 for the Indices that correspond to treatment.
- BlockRandomizationSubjectsUsingRPackage.R
The function named “BlockRandomizationSubjectsUsingRPackage.R” in the file makes use of pbrPar() function from the library named “randomizeR” to perform the Block randomization.
Description:
Imbalances between groups can be minimized in small sample–size studies by restricting the randomization procedure. Restricted randomization means that randomization is applied in a manner that helps ensure the desired proportions of treatment groups, beyond random chance, within defined groups of patients.
The permuted block technique randomizes patients between groups within a set of study participants, called a block. Treatment assignments within blocks are determined so that they are random in order but that the desired allocation proportions are achieved exactly within each block.
- LoadrandomizeR.R
This file is used to install the “randomizeR” package for execution of Block Randomization in R.