Skip to content

Randomization Module

Shawn Garbett edited this page Jan 25, 2023 · 1 revision

REDCap's randomization module requires a user to manually upload a csv giving the allocation of the randomizations. These allocations must be produced externally. redcapAPI's allocationTable assists with the generation of these tables to ensure that blocking and stratification are done appropriately.

allocationTable is introduced in version 1.2, which will be released in early 2015

Designing the Randomization Model

The randomization model must be defined using the REDCap user interface.

1. Enable the Randomization Module

From the Project Setup, click the button to enable the randomization module.
Enable the Randomization Module

2. Navigate to the User Rights Page

User Rights

3. Grant Access to the Randomization Setup

Randomization Access

4. Navigate to the Randomization Module

Navigate to Randomization

5. Design the Randomization Model

Use the checkboxes and drop downs to design your randomization scheme. In the example below, we have stratified by age and gender, and will also perform the randomization within each data access group.

The variable names are provided for each variable in the drop down list. The data access group ids are a little harder to get, but we'll show that in a minute.

Be sure to click the button to save the Randomization model when you're done.

Randomization Model

6. If Using Data Access Groups:

If you are not using Data Access Groups, skip to the next page. Otherwise, download one of the sample templates by clicking one of the buttons in Step 2.

Sample Templates

Open the sample file and look at the Data Access Group IDs in the lower right. You want to use the numeric ID given, not the labeled description.

Data Access Group ID

7. Generate Your Allocation Tables

Use the following code to generate allocation tables for your randomization model.
In this example, we will use 50 replicates per stratum with a block size of 4.

library(redcapAPI)
rcon <- redcapConnection(url=[URL], token=[TOKEN])
proj <- redcapProjectInfo(rcon)

Randomize <- allocationTable(rcon, random="randomize", 
                             strata=c("gender", "age"), 
                             dag.id=c("1330", "1331"), 
                             replicates=200, 
                             block.size=c(8, 4, 2), 
                             block.size.shift = c(0, .48, .9),
                             seed.dev=205, seed.prod=1510,  
                             proj=proj)

write.csv(Randomize$allocate_dev, file=[Devel_File])
write.csv(Randomize$allocate_prod, file=[Prod_File])

The list returned by \code{allocateTable} will also return the seeds used for the randomization in each stratum and the ultimate blocking scheme used in the randomization.

8. Upload Your Allocation Tables

Use the dialog in Step 3 of the Randomization Module to upload your allocation tables.

Upload Allocations