id | stratum | block.id | block.size | treatment |
---|---|---|---|---|
No data |
单个值,为整数或null
随机化的最小受试者数量
随机化的治疗或因子水平的数量
不同处理或因子水平的标签名称
可选的整数或字符串作为 id 列值的前缀
指定正在生成的层的可选字符串
指定要使用的随机块大小的整数向量
可选的整数或字符串作为 block.id 列的前缀
本网站基于R语言的blockrand(v1.5)包实现随机化。此功能为临床试验(或任何每次只接受一个受试者的实验)创建随机分配。随机化在区块内完成,以便在整个试验过程中,治疗之间的平衡保持接近相等。
所谓随机数,实际是“伪随机数”, 是从一组起始值(称为种子), 按照某种递推算法向前递推得到的。 所以从同一种子出发,得到的随机数序列是相同的。
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)
【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
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
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 the id column of the output will be a sequence of integers starting at the value of id.prefix. 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.
Schulz, K. and Grimes, D. (2002): Unequal group sizes in randomized trials: guarding against guessing, The Lancet, 359, pp 966--970.
https://www.rdocumentation.org/packages/simEd/versions/2.0.1/topics/set.seed
https://www.rdocumentation.org/packages/blockrand/versions/1.5/topics/blockrand
plotblockrand, sample, rbind
# NOT RUN {
## 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 {
plotblockrand(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)
# }
# NOT RUN {
# }