[R] Paid R Help

Marc Schwartz marc_schwartz at me.com
Thu Jun 2 22:52:40 CEST 2011


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

> Hello R people,
> 
> I am looking to pay someone to help write some R code.
> 
> Inputs:
> Study identifier:   ID Number for the study, each ID number is for one study only each block set should only be used for that study.   This will require that you store the results from the blocks someplace on the file system.
> Trait #1:  dichotomous rural / urban
> Trait #2:  dichotomous sick / healthy
> Assignment Ratio:  a number between 0 and 1, usually .5 but, for this study it would be .67. Indicating the % of participants to be randomized to the intervention arm.  1-the Assignment Ratio will be the number of participants to be randomized to the control arm.   So for example, for each  6 person block,  4 would be assigned to intervention and 2 to control.
> Four blocks will be in action at any given time one each  for each of the following combinations FOR EACH STUDY ID.
> Rural + sick      Rural + healthy   urban + sick     urban + healthy
> The status of where we are in each block for each study will need to be stored somewhere.
> 
> Returned value
> Study Arm:   dichotomous  Intervention / Control
> 
> There might be some code that helps do this in R already.
> http://rss.acs.unt.edu/Rdoc/library/blockrand/html/blockrand.package.html
> 
> http://docs.google.com/viewer?a=v&q=cache:BnSasjcO0xQJ:personality-project.org/revelle/syllabi/205/block.randomization.pdf+r+block+randomization&hl=en&gl=us&pid=bl&srcid=ADGEESj9HQShWGzlfTJZOQQdCyohIcLV8HptDj8JZqsXbzDIZLUM6J3BDe6dpTsw95JcG6QDeiPn
> 
> The purpose of block randomization is to insure equal distribution the two traits (in this case urban / rural and sick/healthy) across the two study arms.
> 
> 
> This will be called as each person enrolls in the study. So you will need to store the block data some place per study id.
> 
> I am happy to pay someone to work on this problem for me.  Please contact me off list, if you are willing and able.
> 
> Thanks,
> Michael  Hess
> University of Michigan


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)


> Blocks1
   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



More information about the R-help mailing list