Package 'CARM'

Title: Covariate-Adjusted Adaptive Randomization via Mahalanobis-Distance
Description: In randomized controlled trial (RCT), balancing covariate is often one of the most important concern. CARM package provides functions to balance the covariates and generate allocation sequence by covariate-adjusted Adaptive Randomization via Mahalanobis-distance (ARM) for RCT. About what ARM is and how it works please see Y. Qin, Y. Li, W. Ma, H. Yang, and F. Hu (2022). "Adaptive randomization via Mahalanobis distance" Statistica Sinica. <doi:10.5705/ss.202020.0440>. In addition, the package is also suitable for the randomization process of multi-arm trials. For details, please see Yang H, Qin Y, Wang F, et al. (2023). "Balancing covariates in multi-arm trials via adaptive randomization" Computational Statistics & Data Analysis.<doi:10.1016/j.csda.2022.107642>.
Authors: Haoyu Yang [aut], Fanglu Chen [aut, cre], Yichen Qin [aut], Yang Li [aut]
Maintainer: Fanglu Chen <[email protected]>
License: GPL (>= 2)
Version: 1.1.0
Built: 2025-02-24 04:17:48 UTC
Source: https://github.com/fanglu-chen/carm

Help Index


CARM:Covariate-adjusted Adaptive Randomization via Mahalanobis-distance

Description

The CARM package provides function of implement of randomization:

ARM functions

please ?ARM and ?ARMM to view function usage


Adaptive Randomization via Mahalanobis Distance

Description

Allocates patients to one of two treatments using Adaptive Randomization via Mahalanobis Distance proposed by Yichen Qin,Yang Li, Wei Ma, Haoyu Yang, and Feifang Hu.(2022)

Usage

ARM(covariate, assignment, q = 0.75)

Arguments

covariate

a data frame. A row of the dataframe corresponds to the covariate profile of a patient.

assignment

a vector. If partial patients had been allocated , please input their allocation. IF all the patients are not be allocated, please input 'assignment = NA' directly.

q

the biased coin probability. qq should be larger than 1/2 and less than 1, default = 0.75

Details

Suppose that nn patients are to be assigned to two treatment groups. Consider pp continuous covariates for each patient. TiT_i is the assignment of the iith patient. The proposed procedure to assign units to treatment groups, namely adaptive randomization via Mahalanobis distance (ARM), is outlined below.

(1) Arrange all nn units randomly into a sequence x1,...,xnx_1,...,x_n.

(2) Assign the first two units with T1=1T_1=1 and T2=2T_2=2.

(3) Suppose that 2i2i units have been assigned to treatment groups, for the 2i+12i+1-th and 2i+22i+2-th units:

(3a) If the 2i+12i+1-th unit is assigned to treatment 1 and the 2i+22i+2-th unit to treatment 2, then calculate the potential Mahalanobis distance, between the updated treatment groups. with 2i+22i+2 units, M1(2i+2)M_1(2i + 2).

(3b) Similarly, if the 2i+12i+1-th unit is assigned to treatment 2 and the 2i+22i+2-th unit to treatment 1, then calculate the other potential Mahalanobis distance, M2(2i+2)M_2(2i + 2).

(4) Assign the 2i+12i+1-th unit to treatment groups according to the following probabilities:

if M1(2i+2)<M2(2i+2)M_1(2i + 2) < M_2(2i + 2), P(T2i+1=1)=qP(T_{2i+1} = 1)= q;

if M1(2i+2)>M2(2i+2)M_1(2i + 2) > M_2(2i + 2), P(T2i+1=1)=1qP(T_{2i+1} = 1)= 1-q;

if M1(2i+2)=M2(2i+2)M_1(2i + 2) = M_2(2i + 2), P(T2i+1=1)=0.5P(T_{2i+1} = 1)= 0.5.

(5) Repeat the last two steps until all units are assigned. If n is odd, assign the last unit to two treatments with equal probabilities.

Mahalanobis distance M(n)M(n) between the sample means across different treatment groups is:

M(n)=np(1p)(x1^x2^)Tcov(x)1(x1^x2^M(n)= np(1-p)(\hat{x_1} - \hat{x_2})^Tcov(x)^{-1}(\hat{x_1} - \hat{x_2}

See the reference for more details.

Value

An object of class "ARM" is a list containing the following components:

assignment

Allocation of patients.

sample_size

The number of patients in treatment 1 and treatment 2 respectively.

Mahalanobis_Distance

Mahalanobis distance between treatment groups 1 and 2.

References

Qin, Y., Y. Li, W. Ma, H. Yang, and F. Hu (2022). Adaptive randomization via mahalanobis distance. Statistica Sinica.DOI:<10.5705/ss.202020.0440>.

Examples

library(MASS)
#simulate covariates of patients
p <- 6; n <- 30
sigma <- diag(p); mean <- c(rep(0,p))
data <- mvrnorm(n, mean, sigma)
covariate <- as.data.frame(data)
#IF all the patients are not be allocated
ARM(covariate = covariate, assignment = NA, q=0.75)
#IF you had allocated partial patients
ARM(covariate = covariate,assignment = c(1,2),q=0.75)

Adaptive Randomization via Mahalanobis distance for Multi-arm design

Description

Randomize patients into treatment groups for multi-arm trials using ARMM proposed by Haoyu Yang, Yichen Qin, Yang Li, Fan Wang, and Feifang Hu.(2022)

Usage

ARMM(covariate, assignment, K, q = 0.75, method)

Arguments

covariate

a data frame. A row of the dataframe corresponds to the covariate profile of a patient.

assignment

a vector. If partial patients had been allocated , please input their allocation. IF all the patients are not be allocated, please input 'assignment = NA' directly.

K

an integer; number of arms of the trial.

q

the biased coin probability. qq should be larger than 1/2 and less than 1, default = 0.75

method

Methods for calculating Mahalanobis distance, input one of these texts: 'mean', 'max' or 'median'.

Details

Suppose nn units (participants) are to be assigned to KK treatment groups. For each unit i,i=1,...,ni, i = 1, ..., n and treatment j,j=1,...,Kj, j = 1, ..., K, define the assignment matrix [Tij]nK[T_{ij}]^{n*K}, where Tij=1T_{ij}=1 indicates unit ii receives treatment jj. Consider pp continuous covariates, let xi=(xi1,...,xin)Tx_i = (x_{i1},...,x_{in})^T.

The proposed method, namely the adaptive randomization via Mahalanobis distance for multi-arm design (ARMM), is outlined below. The implement of ARMM is similar to ARM.

First assume that nn units are in a sequence and then assign the first KK units to KK treatment groups randomly as the initialization. Then, the following units are assigned in blocks of KK sequentially and adaptively until all the units are assigned. For KK units are assigned to KK groups, there are in total K!K! possible allocations. Calculate K!K! potential overall covariate imbalance measurement according to pairwise Mahalanobis distance under the K!K! possible allocations. Choose the allocation which corresponds to the smallest Mahalanobis distance with a probability of qq across all potential allocations. Repeat the process until all units are assigned.

For any pair of treatments ss and tt among the KK treatment groups, calculate the Mahalanobis distance by:

Ms,t(n)=2n/K/K(x^1x^2)Tcov(x)1(x^1x^2)M_{s,t}(n) = 2n/K/K(\hat{x}_1 -\hat{x}_2)^Tcov(x)^{-1}(\hat{x}_1 -\hat{x}_2)

In total, there are CK2C_K^2 pairs of Mahalanobis distances among KK treatment groups.Finally, calculate the mean, the median or the maximum to represent the total imbalance.

See the reference for more details.

Value

An object of class "ARMM" is a list containing the following components:

assignment

Allocation of patients.

sample_size

The number of patients from treatment 1 to treatment KK respectively.

Mahalanobis_Distance

Mahalanobis distance among treatment groups .

References

Yang H, Qin Y, Wang F, et al. Balancing covariates in multi-arm trials via adaptive randomization. Computational Statistics & Data Analysis, 2023, 179: 107642. https://doi.org/10.1016/j.csda.2022.107642

Examples

library(MASS)
#simulate covariates of patients
p <- 6; n <- 30
sigma <- diag(p); mean <- c(rep(0,p))
data <- mvrnorm(n, mean, sigma)
covariate <- as.data.frame(data)
#IF all the patients are not be allocated
ARMM(covariate = covariate, assignment = NA, K = 3, q = 0.75, method = 'mean')
#IF you had allocated partial patients
ARMM(covariate = covariate, assignment = c(1,2), K=4, q=0.75, method = 'max')