blockrand             package:blockrand             R Documentation

_G_e_n_e_r_a_t_e _a _b_l_o_c_k _r_a_n_d_o_m_i_z_a_t_i_o_n _f_o_r _a _c_l_i_n_i_c_a_l _t_r_i_a_l

_D_e_s_c_r_i_p_t_i_o_n:

     This function creates random assignments for clinical trials (or
     any experiment where the subjects come one at a time).  The
     randomization is done within blocks so that the balance between
     treatments stays close to equal throughout the trial.

_U_s_a_g_e:

     blockrand(n, num.levels = 2, levels = LETTERS[seq(length = num.levels)],
     id.prefix, stratum, block.sizes = 1:4, block.prefix,
     uneq.beg=FALSE, uneq.mid=FALSE, uneq.min=0, uneq.maxit=10)

_A_r_g_u_m_e_n_t_s:

       n: The minimum number of subjects to randomize 

num.levels: The number of treatments or factor levels to randomize
          between 

  levels: A character vector of labels for the different treatments or
          factor levels 

id.prefix: Optional integer or character string to prefix the id column
          values

 stratum: Optional character string specifying the stratum being
          generated

block.sizes: Vector of integers specifying the sizes of blocks to use 

block.prefix: Optional integer or character string to prefix the
          block.id column 

uneq.beg: Should an unequal block be used at the beginning of the
          randomization 

uneq.mid: Should an unequal block be used in the middle 

uneq.min: what is the minimum difference between the most and least
          common levels in an unequal block 

uneq.maxit: maximum number of tries to get uneq.min difference 

_D_e_t_a_i_l_s:

     This function will randomize subjects to the specified treatments
     within sequential blocks.  The total number of randomizations may
     end up being more than 'n'.

     The final block sizes will actually be the product of 'num.levels'
     and 'block.sizes' (e.g. if there are 2 levels and the default
     block sizes are used (1:4) then the actual block sizes will be
     randomly chosen from the set (2,4,6,8)).

     If 'id.prefix' is not specified then the id column of the output
     will be a sequence of integers from 1 to the number of rows.  If
     'id.prefix' is numeric then this number will be added to the set
     of integers.  If 'id.prefix' is a character string then the
     numbers will be converted to strings (zero padded) and have the
     prefix prepended.

     The 'block.prefix' will be treated in the same way as the
     'id.prefix' for identifying the blocks.  The one difference being
     that the 'block.id' will be converted to a factor in the final
     data frame.

     If 'uneq.beg' and/or 'uneq.mid' are true then an additional block
     will be used at the beginning and/or inserted in the middle that
     is not balanced, this means that the final totals in each group
     may not be exactly equal (but still similar).  This makes it more
     difficult to anticipate future assignments as the numbers will not
     return to equality at the end of each block.

     For stratified studies the 'blockrand' function should run once
     each for each stratum using the 'stratum' argument to specify the
     current stratum (and using 'id.prefix' and 'block.prefix' to keep
     the id's unique).  The separate data frames can then be combined
     using 'rbind' if desired.

_V_a_l_u_e:

     A data frame with the following columns: 

     id:: A unique identifier (number or character string) for each row

stratum:: Optional, if 'stratum' argument is specfied it will be
          replicated in this column

block.id:: An identifier for each block of the randomization, this
          column will be a factor

block.size: The size of each block

treatment: The treatment assignment for each subject

_A_u_t_h_o_r(_s):

     Greg Snow greg.snow@imail.org

_R_e_f_e_r_e_n_c_e_s:

     Schulz, K. and Grimes, D. (2002): Unequal group sizes in
     randomized trials: guarding against guessing, The Lancet, 359, pp
     966-970.

_S_e_e _A_l_s_o:

     'plot.blockrand', 'sample', 'rbind'

_E_x_a_m_p_l_e_s:

     ## stratified by sex, 100 in stratum, 2 treatments
     male <- blockrand(n=100, id.prefix='M', block.prefix='M',stratum='Male')
     female <- blockrand(n=100, id.prefix='F', block.prefix='F',stratum='Female')

     my.study <- rbind(male,female)

     ## Not run: 
     plot.blockrand(my.study,'mystudy.pdf',
        top=list(text=c('My Study','Patient: %ID%','Treatment: %TREAT%'),
                 col=c('black','black','red'),font=c(1,1,4)),
        middle=list(text=c("My Study","Sex: %STRAT%","Patient: %ID%"),
                    col=c('black','blue','green'),font=c(1,2,3)),
        bottom="Call 123-4567 to report patient entry",
        cut.marks=TRUE)
     ## End(Not run)

