Title: | Minimization Randomization |
---|---|
Description: | Randomization schedules are generated in the schemes with k (k>=2) treatment groups and any allocation ratios by minimization algorithms. |
Authors: | Man Jin [aut, cre], Adam Polis [aut], Jonathan Hartzel [aut] |
Maintainer: | Man Jin <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.3 |
Built: | 2024-11-04 05:33:59 UTC |
Source: | https://github.com/cran/Minirand |
The fuction is used to generate treatment assignments based on blocked randomization.
blkrandomization(n, blocksize, block)
blkrandomization(n, blocksize, block)
n |
numeric number of subjects who will be randomized |
blocksize |
numeric value of block size used for blocked randomization |
block |
vector of treatment blocks used for blocked randomization |
trt a sequence of treatment assignments
blocksize <- 4 block <- c(1, 2, 3, 4) # treatment 1, 2, 3, 4 n <- 35 blkrandomization(n, blocksize, block)
blocksize <- 4 block <- c(1, 2, 3, 4) # treatment 1, 2, 3, 4 n <- 35 blkrandomization(n, blocksize, block)
The function is used to generate treatment assignment by minimization algorithms.
Minirand(covmat = covmat, j, covwt = covwt, ratio = ratio, ntrt = ntrt, trtseq = trtseq, method = "Range", result = res, p)
Minirand(covmat = covmat, j, covwt = covwt, ratio = ratio, ntrt = ntrt, trtseq = trtseq, method = "Range", result = res, p)
covmat |
matrix or data frame of covariate factors |
j |
the jth subject in the randomization sequence |
covwt |
vector of weights of the covaraite factors |
ratio |
vector of randomization ratios for each treatment |
ntrt |
numeric number of treatment groups |
trtseq |
vector of a sequence of treatment groups |
method |
the method or algorithm for the minimization randomization |
result |
the treatment assignments in subjetcs achieved so far |
p |
the high probability for new assignment |
treatment assignment for the jth subject
Pocock and Simon (1975), Sequential Treatment Assignment with Balancing for Prognostic Factors in the Controlled Clinical Trial. Biometrics; 103-115.
Jin, Polis, and Hartzel (2019), "Algorithms for minimization randomization and the implementation with an R package". Communications in Statistics-Simulation and Computation; May 2019.
ntrt <- 3 nsample <- 120 trtseq <- c(1, 2, 3) ratio <- c(2, 2, 1) c1 <- sample(seq(1, 0), nsample, replace = TRUE, prob = c(0.4, 0.6)) c2 <- sample(seq(1, 0), nsample, replace = TRUE, prob = c(0.3, 0.7)) c3 <- sample(c(2, 1, 0), nsample, replace = TRUE, prob = c(0.33, 0.2, 0.5)) c4 <- sample(seq(1, 0), nsample, replace = TRUE, prob = c(0.33, 0.67)) covmat <- cbind(c1, c2, c3, c4) # generate the matrix of covariate factors for the subjects # label of the covariates colnames(covmat) = c("Gender", "Age", "Hypertension", "Use of Antibiotics") covwt <- c(1/4, 1/4, 1/4, 1/4) #equal weights res <- rep(100, nsample) # result is the treatment needed from minimization method #gernerate treatment assignment for the 1st subject res[1] = sample(trtseq, 1, replace = TRUE, prob = ratio/sum(ratio)) for (j in 2:nsample) { # get treatment assignment sequentiall for all subjects res[j] <- Minirand(covmat=covmat, j, covwt=covwt, ratio=ratio, ntrt=ntrt, trtseq=trtseq, method="Range", result=res, p = 0.9) } trt1 <- res #Display the number of randomized subjects at covariate factors balance1 <- randbalance(trt1, covmat, ntrt, trtseq) balance1 totimbal(trt = trt1, covmat = covmat, covwt = covwt, ratio = ratio, ntrt = ntrt, trtseq = trtseq, method = "Range")
ntrt <- 3 nsample <- 120 trtseq <- c(1, 2, 3) ratio <- c(2, 2, 1) c1 <- sample(seq(1, 0), nsample, replace = TRUE, prob = c(0.4, 0.6)) c2 <- sample(seq(1, 0), nsample, replace = TRUE, prob = c(0.3, 0.7)) c3 <- sample(c(2, 1, 0), nsample, replace = TRUE, prob = c(0.33, 0.2, 0.5)) c4 <- sample(seq(1, 0), nsample, replace = TRUE, prob = c(0.33, 0.67)) covmat <- cbind(c1, c2, c3, c4) # generate the matrix of covariate factors for the subjects # label of the covariates colnames(covmat) = c("Gender", "Age", "Hypertension", "Use of Antibiotics") covwt <- c(1/4, 1/4, 1/4, 1/4) #equal weights res <- rep(100, nsample) # result is the treatment needed from minimization method #gernerate treatment assignment for the 1st subject res[1] = sample(trtseq, 1, replace = TRUE, prob = ratio/sum(ratio)) for (j in 2:nsample) { # get treatment assignment sequentiall for all subjects res[j] <- Minirand(covmat=covmat, j, covwt=covwt, ratio=ratio, ntrt=ntrt, trtseq=trtseq, method="Range", result=res, p = 0.9) } trt1 <- res #Display the number of randomized subjects at covariate factors balance1 <- randbalance(trt1, covmat, ntrt, trtseq) balance1 totimbal(trt = trt1, covmat = covmat, covwt = covwt, ratio = ratio, ntrt = ntrt, trtseq = trtseq, method = "Range")
The fuction to cound the number of randomized subjects at each level for all covariate factors
randbalance(trt, covmat, ntrt, trtseq)
randbalance(trt, covmat, ntrt, trtseq)
trt |
treatment sequence for all the randomized subjects |
covmat |
matrix or data frame of covariate factors |
ntrt |
numeric number of treatment groups |
trtseq |
vector of a sequence of treatment groups |
the number of randomized subjects at each level for all covariate factors
The function to calculates the total imbalance measured by minimization algorithms
totimbal(trt = trt, covmat = covmat, covwt = covwt, ratio = ratio, ntrt = ntrt, trtseq = trtseq, method = "Range")
totimbal(trt = trt, covmat = covmat, covwt = covwt, ratio = ratio, ntrt = ntrt, trtseq = trtseq, method = "Range")
trt |
treatment sequence for all the randomized subjects |
covmat |
matrix or data frame of covariate factors |
covwt |
vector of weights of the covaraite factors |
ratio |
vector of randomization ratios for each treatment |
ntrt |
numeric number of treatment groups |
trtseq |
vector of a sequence of treatment groups |
method |
the method or algorithm for the minimization randomization |
total imbalance