WBR_Alloc: Allocation Function of Weighted Balance Ratio Design for...

View source: R/CARA_function.R

WBR_AllocR Documentation

Allocation Function of Weighted Balance Ratio Design for Binary and Continuous Response

Description

Calculating the probability of assigning the upcoming patient to treatment A based on the patient's covariates and the previous patients' covariates and responses for Weighted Balance Ratio procedure for binary and continuous response.

Usage

WBR_Alloc(
  ptsb.X,
  ptsb.Z,
  ptsb.Y,
  ptsb.t,
  ptnow.X,
  ptnow.Z,
  weight,
  v = 2,
  response
)

Arguments

ptsb.X

a vector of length n of the predictive covariates of previous patients. Must be binary.

ptsb.Z

a n x k of the prognostic covariates of previous patients. Must be binary.

ptsb.Y

a vector of length n of the responses of previous patients.

ptsb.t

a vector of length n of the treatment allocation of previous patients.

ptnow.X

a binary value of the predictive covariate of the present patient.

ptnow.Z

a vector of length k of the binary prognostic covariate of the present patient.

weight

a vector of length 2+k. The weight of balance ratio in overall,margin and stratum levels.

v

a positive value that controls the randomness of allocation probability function.

response

the type of the response. Options are "Binary" or "Cont".

Details

This function implements a covariate-adjusted response-adaptive design using a weighted balancing ratio rule (WBR) combined with a DBCD-type allocation function.

The first two steps follow Zhao et al. (2022): the first 2K patients are randomized using restricted randomization with K patients in each treatment group. For patient n > 2K, suppose the prognostic covariates \boldsymbol{Z}_n fall into stratum (k_1^*, \ldots, k_J^*).

Define the weighted imbalance ratio \boldsymbol{r}_{n-1}(\boldsymbol{X}_n) for patient n as:

\boldsymbol{r}_{n-1}(\boldsymbol{X}_n) = w_o \frac{\boldsymbol{N}_{n-1}(\boldsymbol{X}_n)}{N_{n-1}(\boldsymbol{X}_n)} + \sum_{j=1}^{J} w_{m,j} \frac{\boldsymbol{N}_{(j; k_j^*), n-1}(\boldsymbol{X}_n)}{N_{(j; k_j^*), n-1}(\boldsymbol{X}_n)} + w_s \frac{\boldsymbol{N}_{(k_1^*, \ldots, k_J^*), n-1}(\boldsymbol{X}_n)}{N_{(k_1^*, \ldots, k_J^*), n-1}(\boldsymbol{X}_n)},

where w_o, w_{m,1}, ..., w_{m,J}, w_s are non-negative weights that sum to 1.

Based on the patient’s covariates, the target allocation probability \hat{\rho}_{n-1}(\boldsymbol{X}_n) is estimated from previous data.

The final probability of assigning patient n to treatment k is computed using a CARA-type allocation function from Hu and Zhang (2009):

\phi_{n,k}(\boldsymbol{X}_n) = g_k(\boldsymbol{r}_{n-1}(\boldsymbol{X}_n), \hat{\rho}_{n-1}(\boldsymbol{X}_n)) = \frac{ \hat{\rho}_{n-1} \left( \frac{\hat{\rho}_{n-1}}{r_{n-1}} \right)^v } { \hat{\rho}_{n-1} \left( \frac{\hat{\rho}_{n-1}}{r_{n-1}} \right)^v + (1 - \hat{\rho}_{n-1}) \left( \frac{1 - \hat{\rho}_{n-1}}{1 - r_{n-1}} \right)^v },

where v \geq 0 is a tuning parameter controlling the degree of randomness. A value of v = 2 is commonly recommended.

This approach combines stratified covariate balancing with covariate-adjusted optimal targeting. More details can be found in Yu(2025).

Value

prob

Probability of assigning the upcoming patient to treatment A.

References

Yu, J. (2025). A New Family of Covariate-Adjusted Response-Adaptive Randomization Procedures for Precision Medicine (Doctoral dissertation, The George Washington University).

Examples

set.seed(123)

# Generate historical data for 400 patients
ptsb.X = sample(c(1, -1), 400, replace = TRUE)  # predictive covariate
ptsb.Z = cbind(
  sample(c(1, -1), 400, replace = TRUE),         # prognostic covariate 1
  sample(c(1, -1), 400, replace = TRUE)          # prognostic covariate 2
)
ptsb.Y = sample(c(1, 0), 400, replace = TRUE)   # binary responses
ptsb.t = sample(c(1, 0), 400, replace = TRUE)   # treatment assignments

# Incoming patient covariates
ptnow.X = 1
ptnow.Z = c(1, -1)

# Calculate allocation probability using WBR method
result = WBR_Alloc(
  ptsb.X = ptsb.X,
  ptsb.Z = ptsb.Z,
  ptsb.Y = ptsb.Y,
  ptsb.t = ptsb.t,
  ptnow.X = ptnow.X,
  ptnow.Z = ptnow.Z,
  weight = rep(0.25, 4),
  response = "Binary"
)

# View probability of assigning to treatment A
result$prob

caradpt documentation built on Aug. 28, 2025, 9:09 a.m.

Related to WBR_Alloc in caradpt...