治疗组中的聚类随机分配

时间:2019-08-23 08:17:55

标签: stata

我有1200个患者,我希望将它们分配到4个随机组和8个集群中。

我可以如下创建组:

generate groups=1
replace groups=2 if id>300
replace groups=3 if id>600
replace groups=4 if id>900

但是,有没有办法在集群级别随机分配这些组?

1 个答案:

答案 0 :(得分:1)

您可以使用命令cluster_ra  社区贡献模块randomizr

clear
set obs 1200

generate clusters = runiformint(1,8)
cluster_ra, cluster_var(clusters) num_arms(4) 

tabulate clusters assignment

           |                 assignment
  clusters |         1          2          3          4 |     Total
-----------+--------------------------------------------+----------
         1 |       137          0          0          0 |       137 
         2 |         0          0          0        160 |       160 
         3 |         0          0        142          0 |       142 
         4 |         0          0        146          0 |       146 
         5 |         0        140          0          0 |       140 
         6 |         0          0          0        154 |       154 
         7 |       165          0          0          0 |       165 
         8 |         0        156          0          0 |       156 
-----------+--------------------------------------------+----------
     Total |       302        296        288        314 |     1,200 

请注意,还有许多其他社区贡献的命令 使各种实验设计的随机化过程自动化。

一些例子:

search randomize, all

ralloc from http://fmwww.bc.edu/RePEc/bocode/r
    'RALLOC': module to design randomized controlled trials / ralloc provides
    a sequence of treatments randomly permuted in / blocks of constant or
    varying size.  If not constant, the / size and order of the blocks are
    also random.  Allocation may / be stratified by one or more variables. 

randomize from http://fmwww.bc.edu/RePEc/bocode/r
    'RANDOMIZE': module to create random assignments for experimental trials,
    including blocking, balance checking, and automated rerandomization /
    randomize conducts random assignment of units to equally sized / groups.
    It can check for balance on a specified list of / covariates. 

stratarand from http://fmwww.bc.edu/RePEc/bocode/s
    'STRATARAND': module to perform stratified random assignment / stratarand
    performs stratified random assignment for equal and / unequally sized
    treatment groups. This function randomly assigns / observations to
    experimental groups in user-specified strata. 

您可以从SSC安装所有这些命令:

ssc install randomizr