View source: R/CARA_function.R
WBR_Alloc | R Documentation |
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.
WBR_Alloc(
ptsb.X,
ptsb.Z,
ptsb.Y,
ptsb.t,
ptnow.X,
ptnow.Z,
weight,
v = 2,
response
)
ptsb.X |
a vector of length |
ptsb.Z |
a |
ptsb.Y |
a vector of length |
ptsb.t |
a vector of length |
ptnow.X |
a binary value of the predictive covariate of the present patient. |
ptnow.Z |
a vector of length |
weight |
a vector of length |
v |
a positive value that controls the randomness of allocation probability function. |
response |
the type of the response. Options are |
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).
prob |
Probability of assigning the upcoming patient to treatment A. |
Yu, J. (2025). A New Family of Covariate-Adjusted Response-Adaptive Randomization Procedures for Precision Medicine (Doctoral dissertation, The George Washington University).
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.