Skip to content
Prev 261726 / 398502 Next

Paid R Help

On Jun 2, 2011, at 2:41 PM, Hess, Michael wrote:

            
Michael,

The means to do this is pretty straightforward using the blockrand() function in the package of the same name, as you reference above.

You essentially have a stratified randomization, based upon two dichotomous factors. You are then doing a 2:1 randomization to the two arms in the study, within each of the four strata.

Using blockrand():

# Set the RNG seed so that you can reproduce the sequence again in the future
set.seed(1)


# Generate 18 randomizations in one of the four strata, such that there will be 
# 3 blocks, each of size 6, with 4 Intervention and 2 Control subjects in each block
# The actual block size used will be num.levels * block.sizes (6 * 1)

Blocks1 <- blockrand(18, num.levels = 6, levels = rep(c("I", "C"), c(4, 2)), 
                     stratum = "Rural + Sick", block.sizes = 1)
id      stratum block.id block.size treatment
1   1 Rural + Sick        1          6         I
2   2 Rural + Sick        1          6         C
3   3 Rural + Sick        1          6         I
4   4 Rural + Sick        1          6         I
5   5 Rural + Sick        1          6         I
6   6 Rural + Sick        1          6         C
7   7 Rural + Sick        2          6         I
8   8 Rural + Sick        2          6         I
9   9 Rural + Sick        2          6         C
10 10 Rural + Sick        2          6         C
11 11 Rural + Sick        2          6         I
12 12 Rural + Sick        2          6         I
13 13 Rural + Sick        3          6         I
14 14 Rural + Sick        3          6         I
15 15 Rural + Sick        3          6         C
16 16 Rural + Sick        3          6         I
17 17 Rural + Sick        3          6         C
18 18 Rural + Sick        3          6         I


It is then up to whatever data management system you are using to properly use the blocks in each stratum correctly, based upon the two characteristics that you are using for stratification.

Just modify the 'stratum' value for each of the other 3 strata and be sure to change the RNG seed before each run so that each subsequent strata has a different sequence. You DO want to keep track of the RNG seed used before each run of blockrand(), so that you can reproduce the sequencing again in the future, if required.

HTH,

Marc Schwartz