Block randomization with blockrand

I would like to do stratified randomization on three variables: gender, age (2 categories) and center (4 categories). So the number of strata is 2X2X4. This makes 16 strata. I would like 50 people per stratum. So I coded it like this (below).

## Stratified on center/ Sexe / Age
C1_ageSup60_male <- blockrand(n=50, id.prefix='C1S60M', block.prefix='C1S60M',stratum='C1_ageSup60_male')
C1_ageSup60_female <- blockrand(n=50, id.prefix='C1S60F', block.prefix='C1S60F',stratum='C1_ageSup60_female')
C1_ageInf60_male<-blockrand(n=50, id.prefix='C1I60M', block.prefix='C1I60F',stratum='C1_ageInf60_male')
C1_ageInf60_female<-blockrand(n=50, id.prefix='C1I60F', block.prefix='C1I60',stratum='C1_ageInf60_female')

C2_ageSup60_male <- blockrand(n=50, id.prefix='C2S60M', block.prefix='C2S60M',stratum='C2_ageSup60_male')
C2_ageSup60_female <- blockrand(n=50, id.prefix='C2S60F', block.prefix='C2S60F',stratum='C2_ageSup60_female')
C2_ageInf60_male<-blockrand(n=50, id.prefix='C2I60M', block.prefix='C2I60M',stratum='C2_ageInf60_male')
C2_ageInf60_female<-blockrand(n=50, id.prefix='C2I60F', block.prefix='C2I60F',stratum='C2_ageInf60_female')


C3_ageSup60_male <- blockrand(n=50, id.prefix='C3S60M', block.prefix='C3S60M',stratum='C3_ageSup60_male')
C3_ageSup60_female <- blockrand(n=50, id.prefix='C3S60F', block.prefix='C3S60F',stratum='C3_ageSup60_female')
C3_ageInf60_male<-blockrand(n=50, id.prefix='C3I60M', block.prefix='C3I60M',stratum='C3_ageInf60_male')
C3_ageInf60_female<-blockrand(n=50, id.prefix='C3I60F', block.prefix='C3I60F',stratum='C3_ageInf60_female')

C4_ageSup60_male <- blockrand(n=50, id.prefix='C4S60M', block.prefix='C4S60M',stratum='C4_ageSup60_male')
C4_ageSup60_female <- blockrand(n=50, id.prefix='C4S60F', block.prefix='C4S60F',stratum='C4_ageSup60_female')
C4_ageInf60_male<-blockrand(n=50, id.prefix='C4I60M', block.prefix='C4I60M',stratum='C4_ageInf60_male')
C4_ageInf60_female<-blockrand(n=50, id.prefix='C4I60F', block.prefix='C4I60F',stratum='C4_ageInf60_female')

I would like to make sure that my program is correct.:relaxed:

Hi @segoro72
I see a couple of typos in lines 3 and 4 of your code: the strings in id.prefix= are not consistent.

Yes you're about id.prefix that I corrected. Except this is the rest of my codes positive ?

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.