| Title: | Covariate-Adjusted Response-Adaptive Designs for Clinical Trials |
|---|---|
| Description: | The caradpt package provides a set of functions for implementing covariate-adjusted response-adaptive procedures with various types of responses. Users can flexibly choose between two functions based on their specific needs for each procedure: Provide real patient data from clinical trials to compute allocation probabilities directly, or use built-in simulation functions to generate synthetic patient data. Detailed methodologies and algorithms used in this package, please refer to the following references: Zhang, L. X., Hu, F., Cheung, S. H., & Chan, W. S. (2007)<doi: 10.1214/009053606000001424> Zhang, L. X. & Hu, F. (2009) <doi: 10.1007/s11766-009-0001-6> Hu, J., Zhu, H., & Hu, F. (2015) <doi:10.1080/01621459.2014.903846> Zhao, W., Ma, W., Wang, F., & Hu, F. (2022) <doi: 10.1002/pst.2160> Mukherjee, A., Jana, S., & Coad, S. (2024) <doi: 10.1177/09622802241287704> Yu, J. (2025).(ProQuest Dissertations & Theses Global. Order No. 31763053). |
| Authors: | Renjie Luo [aut, cre], Feifang Hu [aut, ctb] |
| Maintainer: | Renjie Luo <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-05-26 08:05:42 UTC |
| Source: | https://github.com/jerryluorj/caradpt |
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 Covariate Adjusted Doubly Biased Coin procedure proposed by Zhang and Hu.
CADBCD_Alloc(ptsb.cov, ptsb.t, ptsb.Y, ptnow.cov, v = 2, response, target)CADBCD_Alloc(ptsb.cov, ptsb.t, ptsb.Y, ptnow.cov, v = 2, response, target)
ptsb.cov |
a |
ptsb.t |
a treatment vector of previous patients with length |
ptsb.Y |
a response vector of previous patients with length |
ptnow.cov |
a covariate vector of the incoming patient with length |
v |
a non-negative integer that controls the randomness of CADBCD design. The default value is 2. |
response |
the type of the response. Options are |
target |
the type of optimal allocation target. Options are |
To start, we let be an initial estimate of , and assign subjects to each treatment using a restricted randomization.
Assume that (with ) subjects have been assigned to treatments. Their responses and the corresponding covariates are observed.
We let be an estimate of .
For each , the estimator is based on the observed sample of size , that is, .
Define and .
When the -th subject is ready for randomization and the corresponding covariate is recorded, we assign the patient to treatment 1 with the probability:
and to treatment 2 with probability , where is a constant controlling the degree of randomness—from the most random when to the most deterministic when . See Zhang and Hu(2009) for more details.
prob |
Probability of assigning the upcoming patient to treatment A. |
Zhang, L. X., Hu, F., Cheung, S. H., & Chan, W. S. (2007). Asymptotic properties of covariate-adjusted response-adaptive designs. Annals of Statistics, 35(3), 1166–1182.
Zhang, L. X., & Hu, F. F. (2009). A new family of covariate-adjusted response adaptive designs and their properties. Applied Mathematics—A Journal of Chinese Universities, 24(1), 1–13.
set.seed(123) n_prev = 40 covariates = cbind(Z1 = rnorm(n_prev), Z2 = rnorm(n_prev)) treatment = sample(c(0, 1), n_prev, replace = TRUE) response = rbinom(n_prev, size = 1, prob = 0.6) # Simulate new incoming patient new_patient_cov = c(Z1 = rnorm(1), Z2 = rnorm(1)) # Run allocation function result = CADBCD_Alloc( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = response, ptnow.cov = new_patient_cov, response = "Binary", target = "Neyman" ) print(result$prob)set.seed(123) n_prev = 40 covariates = cbind(Z1 = rnorm(n_prev), Z2 = rnorm(n_prev)) treatment = sample(c(0, 1), n_prev, replace = TRUE) response = rbinom(n_prev, size = 1, prob = 0.6) # Simulate new incoming patient new_patient_cov = c(Z1 = rnorm(1), Z2 = rnorm(1)) # Run allocation function result = CADBCD_Alloc( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = response, ptnow.cov = new_patient_cov, response = "Binary", target = "Neyman" ) print(result$prob)
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 Covariate Adjusted Doubly Biased Coin procedure for survival trial.
CADBCD_Alloc_Surv(ptsb.cov, ptsb.t, ptsb.Y, ptsb.E, ptnow.cov, v = 2, target)CADBCD_Alloc_Surv(ptsb.cov, ptsb.t, ptsb.Y, ptsb.E, ptnow.cov, v = 2, target)
ptsb.cov |
a |
ptsb.t |
a treatment vector of previous patients with length |
ptsb.Y |
a response vector of previous patients with length |
ptsb.E |
a censoring indicator vector (1 = event observed, 0 = censored)with length |
ptnow.cov |
a covariate vector of the incoming patient with length |
v |
a non-negative integer that controls the randomness of CADBCD design. The default value is 2. |
target |
the type of optimal allocation target. Options are |
For the first patients, a restricted randomization procedure is used to allocate them equally to treatments A and B.
After the initial enrollment of patients, adaptive treatment assignment begins from patient onward. Importantly, this adaptive assignment does not require complete observation of outcomes from earlier patients. Instead, at each new patient arrival, the treatment effect parameters are re-estimated via partial likelihood using the accrued survival data subject to dynamic administrative censoring. Specifically, each previously enrolled patient is censored at the current arrival time if their event has not yet occurred. These updated estimates are then used to guide covariate-adjusted allocation.
When the -th patient enters the trial with covariate vector , the probability of assigning this patient to treatment A is computed as:
where is an appropriately chosen allocation function that favors the better-performing treatment arm.
Following Zhang and Hu's CADBCD procedure, let and denote the numbers of patients allocated to treatments A and B after assignments. Let be the target allocation probability for the incoming patient. The average target allocation proportion among the first patients is defined as:
Under the CADBCD scheme, the probability of assigning treatment A to the -th patient is given by:
and to treatment 2 with probability , where is a constant controlling the degree of randomness—from the most random when to the most deterministic when .
similiar procedure for survival responses are used in all other designs.
prob |
Probability of assigning the upcoming patient to treatment A. |
Mukherjee, A., Jana, S., & Coad, S. (2024). Covariate-adjusted response-adaptive designs for semiparametric survival models. Statistical Methods in Medical Research, 09622802241287704.
set.seed(123) n = 40 covariates = cbind(rexp(40),rexp(40)) treatment = sample(c(0, 1), n, replace = TRUE) survival_time = rexp(n, rate = 1) censoring = runif(n) event = as.numeric(survival_time < censoring) new_patient_cov = c(Z1 = 1, Z2 = 0.5) result = CADBCD_Alloc_Surv( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = survival_time, ptsb.E = event, ptnow.cov = new_patient_cov, v = 2, target = "Neyman" ) print(result$prob)set.seed(123) n = 40 covariates = cbind(rexp(40),rexp(40)) treatment = sample(c(0, 1), n, replace = TRUE) survival_time = rexp(n, rate = 1) censoring = runif(n) event = as.numeric(survival_time < censoring) new_patient_cov = c(Z1 = 1, Z2 = 0.5) result = CADBCD_Alloc_Surv( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = survival_time, ptsb.E = event, ptnow.cov = new_patient_cov, v = 2, target = "Neyman" ) print(result$prob)
This function simulates a clinical trial using the Covariate Adjusted Doubly Biased Coin Design (CADBCD) with Binary or Continuous Responses.
CADBCD_Sim(n, thetaA, thetaB, m0 = 40, pts.cov, v = 2, response, target)CADBCD_Sim(n, thetaA, thetaB, m0 = 40, pts.cov, v = 2, response, target)
n |
a positive integer. The value specifies the total number of participants involved in each round of the simulation. |
thetaA |
a vector of length |
thetaB |
a vector of length |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally for estimation. The default value is 40. |
pts.cov |
a |
v |
a non-negative integer that controls the randomness of CADBCD design. The default value is 2. |
response |
the type of the response. Options are |
target |
the type of optimal allocation target. Options are |
A list with the following elements:
method |
The name of the procedure. |
sampleSize |
Total number of patients. |
parameter |
Estimated parameter values. |
assignment |
Treatment assignment vector. |
proportion |
Proportion of patients allocated to treatment A. |
responses |
Simulated response values. |
failureRate |
Proportion of treatment failures (if |
meanResponse |
Mean response value (if |
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) results = CADBCD_Sim(n = 400, pts.cov = cbind(rnorm(400), rnorm(400)), thetaA = c(-1, 1, 1), thetaB = c(3, 1, 1), response = "Binary", target = "Neyman") results ## view the settings results$method results$sampleSize ## view the simulation results results$parameter results$assignments results$proportion results$responses results$failureRateset.seed(123) results = CADBCD_Sim(n = 400, pts.cov = cbind(rnorm(400), rnorm(400)), thetaA = c(-1, 1, 1), thetaB = c(3, 1, 1), response = "Binary", target = "Neyman") results ## view the settings results$method results$sampleSize ## view the simulation results results$parameter results$assignments results$proportion results$responses results$failureRate
This function simulates a clinical trial with time-to-event (survival) outcomes using the Covariate Adjusted Doubly Biased Coin Design (CADBCD). Patient responses are generated under the Cox proportional hazards model, assuming the proportional hazards assumption holds.
CADBCD_Sim_Surv( n, thetaA, thetaB, m0 = 40, pts.cov, v = 2, target, censor.time, arrival.rate )CADBCD_Sim_Surv( n, thetaA, thetaB, m0 = 40, pts.cov, v = 2, target, censor.time, arrival.rate )
n |
a positive integer. The value specifies the total number of participants involved in each round of the simulation. |
thetaA |
a vector of length |
thetaB |
a vector of length |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally for estimation. The default value is 40. |
pts.cov |
a |
v |
a non-negative integer that controls the randomness of CADBCD design. The default value is 2. |
target |
the type of optimal allocation target. Options are |
censor.time |
a positive value. The upper bound to the simulated uniform censor time. |
arrival.rate |
a positive value. The rate of simulated exponential arrival time. |
A list with the following elements:
method |
The name of procedure. |
sampleSize |
Sample size of the trial. |
parameter |
Estimated parameters used to do the simulations. |
N.events |
Total number of events of the trial. |
assignment |
The randomization sequence. |
proportion |
Average allocation proportion for treatment A. |
responses |
The simulated observed survival responses of patients. |
events |
Whether events are observed for patients(1=event,0=censored). |
rejectNull |
Whether the study to detect a significant difference of treatment effect using Wald test. |
set.seed(123) ## Run CADBCD simulation with survival response results = CADBCD_Sim_Surv( thetaA = c(0.1, 0.1), thetaB = c(-1, 0.1), n = 400, pts.cov = cbind(sample(c(1, 0), 400, replace = TRUE), rnorm(400)), target = "RSIHR", censor.time = 2, arrival.rate = 150 )set.seed(123) ## Run CADBCD simulation with survival response results = CADBCD_Sim_Surv( thetaA = c(0.1, 0.1), thetaB = c(-1, 0.1), n = 400, pts.cov = cbind(sample(c(1, 0), 400, replace = TRUE), rnorm(400)), target = "RSIHR", censor.time = 2, arrival.rate = 150 )
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 CARAEE procedure.
CARAEE_Alloc(ptsb.cov, ptsb.t, ptsb.Y, ptnow.cov, gamma, response)CARAEE_Alloc(ptsb.cov, ptsb.t, ptsb.Y, ptnow.cov, gamma, response)
ptsb.cov |
a |
ptsb.t |
a treatment vector of previous patients with length |
ptsb.Y |
a response vector of previous patients with length |
ptnow.cov |
a covariate vector of the incoming patient with length |
gamma |
a non-negative number. A tuning parameter that reflects the importance of the efficiency component compared to the ethics component. |
response |
the type of the response. Options are |
Covariate-Adjusted Response-Adaptive with Ethics and Efficiency (CARAEE) Design: The CARAEE procedure balances both ethical considerations and statistical efficiency when assigning subjects to treatments.
As a start-up rule, subjects are assigned to each treatment using a balanced randomization scheme.
Assume that subjects have been assigned, and their responses and covariates are observed. Let , where is the maximum likelihood estimate of the treatment-specific parameter based on the data for treatment group .
For the incoming subject with covariates , we define the efficiency and ethics measures for each treatment as:
The allocation probability of assigning subject to treatment 1 is given by:
This allocation rule is scale-invariant in both efficiency and ethics components due to its ratio-based form. The tuning parameter controls the trade-off between the two: when , the assignment is based purely on ethical considerations; larger values of increase the emphasis on statistical efficiency. More details can be found in Hu, Zhu & Zhang(2015).
prob |
Probability of assigning the upcoming patient to treatment A for binary and continuous response. |
Hu, J., Zhu, H., & Hu, F. (2015). A unified family of covariate-adjusted response-adaptive designs based on efficiency and ethics. Journal of the American Statistical Association, 110(509), 357–367.
set.seed(123) n_prev = 40 covariates = cbind(Z1 = rnorm(n_prev), Z2 = rnorm(n_prev)) treatment = sample(c(0, 1), n_prev, replace = TRUE) response = rbinom(n_prev, size = 1, prob = 0.6) # Simulate new incoming patient new_patient_cov = c(Z1 = rnorm(1), Z2 = rnorm(1)) # Run allocation function result = CARAEE_Alloc( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = response, ptnow.cov = new_patient_cov, response = "Binary", gamma=1 ) print(result$prob)set.seed(123) n_prev = 40 covariates = cbind(Z1 = rnorm(n_prev), Z2 = rnorm(n_prev)) treatment = sample(c(0, 1), n_prev, replace = TRUE) response = rbinom(n_prev, size = 1, prob = 0.6) # Simulate new incoming patient new_patient_cov = c(Z1 = rnorm(1), Z2 = rnorm(1)) # Run allocation function result = CARAEE_Alloc( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = response, ptnow.cov = new_patient_cov, response = "Binary", gamma=1 ) print(result$prob)
Calculating the probability of assigning the upcoming patient to treatment A based on the patient's covariates and the previous patients' covariates and responses using CARA Designs Based on Efficiency and Ethics for survival trial.
CARAEE_Alloc_Surv( ptsb.cov, ptsb.t, ptsb.Y, ptsb.E, ptnow.cov, gamma, event.prob )CARAEE_Alloc_Surv( ptsb.cov, ptsb.t, ptsb.Y, ptsb.E, ptnow.cov, gamma, event.prob )
ptsb.cov |
a |
ptsb.t |
a treatment vector of previous patients with length |
ptsb.Y |
a response vector of previous patients with length |
ptsb.E |
a censoring indicator vector (1 = event observed, 0 = censored)with length |
ptnow.cov |
a covariate vector of the incoming patient with length |
gamma |
a non-negative number. A tuning parameter that reflects the importance of the efficiency component compared to the ethics component. |
event.prob |
a vector with length 2. The probability of events of upcoming patient for two treatments. |
prob |
Probability of assigning the upcoming patient to treatment A. |
set.seed(123) n = 40 covariates = cbind(rexp(40),rexp(40)) treatment = sample(c(0, 1), n, replace = TRUE) survival_time = rexp(n, rate = 1) censoring = runif(n) event = as.numeric(survival_time < censoring) new_patient_cov = c(Z1 = 1, Z2 = 0.5) result = CARAEE_Alloc_Surv( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = survival_time, ptsb.E = event, ptnow.cov = new_patient_cov, gamma=1, event.prob = c(0.5,0.7) ) print(result$prob)set.seed(123) n = 40 covariates = cbind(rexp(40),rexp(40)) treatment = sample(c(0, 1), n, replace = TRUE) survival_time = rexp(n, rate = 1) censoring = runif(n) event = as.numeric(survival_time < censoring) new_patient_cov = c(Z1 = 1, Z2 = 0.5) result = CARAEE_Alloc_Surv( ptsb.cov = covariates, ptsb.t = treatment, ptsb.Y = survival_time, ptsb.E = event, ptnow.cov = new_patient_cov, gamma=1, event.prob = c(0.5,0.7) ) print(result$prob)
This function simulates a clinical trial using CARA Designs Based on Efficiency and Ethics (CARAEE) with Binary or Continuous Responses.
CARAEE_Sim(n, thetaA, thetaB, m0 = 40, pts.cov, response, gamma)CARAEE_Sim(n, thetaA, thetaB, m0 = 40, pts.cov, response, gamma)
n |
a positive integer. The value specifies the total number of participants involved in each round of the simulation. |
thetaA |
a vector of length |
thetaB |
a vector of length |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally for estimation. The default value is 40. |
pts.cov |
a |
response |
the type of the response. Options are |
gamma |
a non-negative number. A tuning parameter that reflects the importance of the efficiency component compared to the ethics component. |
A list with the following elements:
method |
The name of the procedure. |
sampleSize |
Total number of patients. |
parameter |
Estimated parameter values. |
assignment |
Treatment assignment vector. |
proportion |
Proportion of patients allocated to treatment A. |
responses |
Simulated response values. |
failureRate |
Proportion of treatment failures (if |
meanResponse |
Mean response value (if |
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) results = CARAEE_Sim(n = 400, pts.cov = cbind(rnorm(400), rnorm(400)), thetaA = c(-1, 1, 1), thetaB = c(3, 1, 1), response = "Binary", gamma=1)set.seed(123) results = CARAEE_Sim(n = 400, pts.cov = cbind(rnorm(400), rnorm(400)), thetaA = c(-1, 1, 1), thetaB = c(3, 1, 1), response = "Binary", gamma=1)
This function simulates a clinical trial with time-to-event (survival) outcomes using the CARA Designs Based on Efficiency and Ethics for Survival Response(CARAEE). Patient responses are generated under the Cox proportional hazards model, assuming the proportional hazards assumption holds.
CARAEE_Sim_Surv( n, thetaA, thetaB, m0 = 40, pts.cov, gamma, censor.time, arrival.rate )CARAEE_Sim_Surv( n, thetaA, thetaB, m0 = 40, pts.cov, gamma, censor.time, arrival.rate )
n |
a positive integer. The value specifies the total number of participants involved in each round of the simulation. |
thetaA |
a vector of length |
thetaB |
a vector of length |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally for estimation. The default value is 40. |
pts.cov |
a |
gamma |
a non-negative number. A tuning parameter that reflects the importance of the efficiency component compared to the ethics component. |
censor.time |
a positive value. The upper bound to the simulated uniform censor time. |
arrival.rate |
a positive value. The rate of simulated exponential arrival time. |
A list with the following elements:
method |
The name of procedure. |
sampleSize |
Sample size of the trial. |
parameter |
Estimated parameters used to do the simulations. |
N.events |
Total number of events of the trial. |
assignment |
The randomization sequence. |
proportion |
Average allocation proportion for treatment A. |
responses |
The simulated observed survival responses of patients. |
events |
Whether events are observed for patients(1=event,0=censored). |
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) results = CARAEE_Sim_Surv( thetaA = c(0.1, 0.1), thetaB = c(-1, 0.1), n = 400, pts.cov = cbind(sample(c(1, 0), 400, replace = TRUE), rnorm(400)), gamma=1, censor.time = 2, arrival.rate = 150 )set.seed(123) results = CARAEE_Sim_Surv( thetaA = c(0.1, 0.1), thetaB = c(-1, 0.1), n = 400, pts.cov = cbind(sample(c(1, 0), 400, replace = TRUE), rnorm(400)), gamma=1, censor.time = 2, arrival.rate = 150 )
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 )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 patients are randomized using restricted randomization with patients in each treatment group. For patient , suppose the prognostic covariates fall into stratum .
Define the weighted imbalance ratio for patient as:
where , , ..., , are non-negative weights that sum to 1.
Based on the patient’s covariates, the target allocation probability is estimated from previous data.
The final probability of assigning patient to treatment is computed using a CARA-type allocation function from Hu and Zhang (2009):
where is a tuning parameter controlling the degree of randomness. A value of 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$probset.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
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 survival response.
WBR_Alloc_Surv( ptsb.X, ptsb.Z, ptsb.Y, ptsb.t, ptsb.E, ptnow.X, ptnow.Z, v = 2, weight )WBR_Alloc_Surv( ptsb.X, ptsb.Z, ptsb.Y, ptsb.t, ptsb.E, ptnow.X, ptnow.Z, v = 2, weight )
ptsb.X |
a vector of length |
ptsb.Z |
a |
ptsb.Y |
a vector of length |
ptsb.t |
a vector of length |
ptsb.E |
a vector of length |
ptnow.X |
a binary value of the predictive covariate of the present patient. |
ptnow.Z |
a vector of length |
v |
a positive value that controls the randomness of allocation probability function. |
weight |
a vector of length |
prob |
Probability of assigning the upcoming patient to treatment A. |
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 = rexp(400, rate = 1) # observed time ptsb.E = sample(c(1, 0), 400, replace = TRUE) # event indicator (1=event, 0=censored) 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 for survival response result = WBR_Alloc_Surv( ptsb.X = ptsb.X, ptsb.Z = ptsb.Z, ptsb.Y = ptsb.Y, ptsb.E = ptsb.E, ptsb.t = ptsb.t, ptnow.X = ptnow.X, ptnow.Z = ptnow.Z, weight = rep(0.25, 4) ) # View probability of assigning to treatment A result$probset.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 = rexp(400, rate = 1) # observed time ptsb.E = sample(c(1, 0), 400, replace = TRUE) # event indicator (1=event, 0=censored) 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 for survival response result = WBR_Alloc_Surv( ptsb.X = ptsb.X, ptsb.Z = ptsb.Z, ptsb.Y = ptsb.Y, ptsb.E = ptsb.E, ptsb.t = ptsb.t, ptnow.X = ptnow.X, ptnow.Z = ptnow.Z, weight = rep(0.25, 4) ) # View probability of assigning to treatment A result$prob
This function simulates a trial using Weighted Balance Ratio design for binary and continuous responses.
WBR_Sim(n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, response, weight, v = 2)WBR_Sim(n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, response, weight, v = 2)
n |
a positive integer. The sample size of the simulated data. |
mu |
a vector of length 2. The true parameters of treatment. |
beta |
a vector of length 2. The true parameters of predictive covariate and interaction with treatment. |
gamma |
a vector of length k. The true parameters of prognostic covariates. |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally to both treatments. |
pts.X |
a vector of length n. The vector of patients' binary predictive covariates. |
pts.Z |
a matrix of |
response |
the type of the response. Options are |
weight |
a vector of length |
v |
a positive value that controls the randomness of allocation probability function. |
method |
The name of procedure. |
sampleSize |
The sample size of the trial. |
assignment |
The randomization sequence. |
X1proportion |
Average allocation proportion for treatment A when predictive covariate equals the smaller value. |
X2proportion |
Average allocation proportion for treatment A when predictive covariate equals the larger value. |
proportion |
Average allocation proportion for treatment A. |
failureRate |
Proportion of treatment failures (if |
meanResponse |
Mean response value (if |
#'
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) # Simulation settings n = 400 # total number of patients mu = c(0.8, 0.8) # treatment effects (muA, muB) beta = c(0.8, -0.8) # predictive effect and interaction gamma = c(0.8, 0.8) # prognostic covariate effects weight = rep(0.25, 4) # weights for imbalance components # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run simulation for continuous response result = WBR_Sim( n = n, mu = mu, beta = beta, gamma = gamma, pts.X = pts.X, pts.Z = pts.Z, response = "Cont", weight = weight )set.seed(123) # Simulation settings n = 400 # total number of patients mu = c(0.8, 0.8) # treatment effects (muA, muB) beta = c(0.8, -0.8) # predictive effect and interaction gamma = c(0.8, 0.8) # prognostic covariate effects weight = rep(0.25, 4) # weights for imbalance components # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run simulation for continuous response result = WBR_Sim( n = n, mu = mu, beta = beta, gamma = gamma, pts.X = pts.X, pts.Z = pts.Z, response = "Cont", weight = weight )
This function simulates a trial using Weighted Balance Ratio design for survival responses.
WBR_Sim_Surv( n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, censor.time, arrival.rate, weight, v = 2 )WBR_Sim_Surv( n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, censor.time, arrival.rate, weight, v = 2 )
n |
a number. The sample size of the simulated data. |
mu |
a number. The true parameters of treatment effect. |
beta |
a vector of length 2. The true parameters of predictive covariate and interaction with treatment. |
gamma |
a vector of length k. The true parameters of prognostic covariates. |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally to both treatments. |
pts.X |
a vector of length n. The vector of patients' binary predictive covariates. |
pts.Z |
a matrix of |
censor.time |
a positive number. The upper bound of the uniform censor time in year. |
arrival.rate |
a positive integer. The arrival rate of patients each year. |
weight |
a vector of length |
v |
a positive value that controls the randomness of allocation probability function. |
A list with the following elements:
method |
The name of procedure. |
sampleSize |
The sample size of the trial. |
assignment |
The randomization sequence. |
X1proportion |
Average allocation proportion for treatment A when predictive covariate equals the smaller value. |
X2proportion |
Average allocation proportion for treatment A when predictive covariate equals the larger value. |
proportion |
Average allocation proportion for treatment A. |
N.events |
Total number of events occured of the trial. |
responses |
Observed survival responses of patients. |
events |
Survival status vector of patients(1=event,0=censored) |
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) # Simulation settings n = 400 # total number of patients mu = 0.5 # treatment effect (log hazard ratio) beta = c(0.5, -0.5) # predictive effect and interaction gamma = c(0.5, 0.5) # prognostic covariate effects censor.time = 2 # maximum censoring time (years) arrival.rate = 1.5 # arrival rate per year weight = rep(0.25, 4) # imbalance weights for overall, margins, and stratum # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run simulation for survival outcome result = WBR_Sim_Surv( n = n, mu = mu, beta = beta, gamma = gamma, pts.X = pts.X, pts.Z = pts.Z, censor.time = censor.time, arrival.rate = arrival.rate, weight = weight )set.seed(123) # Simulation settings n = 400 # total number of patients mu = 0.5 # treatment effect (log hazard ratio) beta = c(0.5, -0.5) # predictive effect and interaction gamma = c(0.5, 0.5) # prognostic covariate effects censor.time = 2 # maximum censoring time (years) arrival.rate = 1.5 # arrival rate per year weight = rep(0.25, 4) # imbalance weights for overall, margins, and stratum # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run simulation for survival outcome result = WBR_Sim_Surv( n = n, mu = mu, beta = beta, gamma = gamma, pts.X = pts.X, pts.Z = pts.Z, censor.time = censor.time, arrival.rate = arrival.rate, weight = weight )
Calculating the probability of assigning the upcoming patient to treatment A based on the patient's predictive covariates and the previous patients' predictive covariates and responses for Zhao's New procedure.
ZhaoNew_Alloc( ptsb.X, ptsb.Z, ptsb.t, ptsb.Y, ptnow.X, ptnow.Z, response, omega, p = 0.8 )ZhaoNew_Alloc( ptsb.X, ptsb.Z, ptsb.t, ptsb.Y, ptnow.X, ptnow.Z, response, omega, p = 0.8 )
ptsb.X |
a vector of length |
ptsb.Z |
a |
ptsb.t |
a vector of length |
ptsb.Y |
a vector of length |
ptnow.X |
a binary value of the predictive covariate of the present patient. |
ptnow.Z |
a vector of length |
response |
the type of the response. Options are |
omega |
a vector of length |
p |
a positive value between 0.75 and 0.95. The probability parameter of Efron's biased coin design. |
This function implements a stratified covariate-adjusted response-adaptive design that balances treatment allocation within and across strata defined by prognostic covariates.
The first patients are randomized using a restricted randomization procedure, with patients assigned to each treatment. For patient , let denote predictive covariates, and denote stratification covariates, placing the patient into stratum .
Based on the covariate profiles and responses of the first patients, we estimate the target allocation probability for the current patient.
If assigned to treatment 1, we compute imbalance measures between actual and target allocation at three levels:
Overall imbalance: ,
Marginal imbalance: ,
Within-stratum imbalance: .
These are combined into a weighted imbalance function:
A similar imbalance is defined for treatment 2. The patient is then assigned to treatment 1 with probability:
where is a biasing function satisfying and for . One common choice is Efron's biased coin function:
with and .
This design unifies covariate-adjusted response-adaptive randomization and marginal/stratified balance. It reduces to Hu & Hu's design when is excluded, and to CARA designs when is ignored. More detail can be found in Zhao et al.(2022).
prob |
Probability of assigning the upcoming patient to treatment A. |
Zhao, W., Ma, W., Wang, F., & Hu, F. (2022). Incorporating covariates information in adaptive clinical trials for precision medicine. Pharmaceutical Statistics, 21(1), 176–195.
set.seed(123) ptsb.X = sample(c(1, -1), 400, replace = TRUE) ptsb.Z = cbind( sample(c(1, -1), 400, replace = TRUE), sample(c(1, -1), 400, replace = TRUE) ) ptsb.Y = sample(c(1, 0), 400, replace = TRUE) ptsb.t = sample(c(1, 0), 400, replace = TRUE) ## Incoming patient ptnow.X = 1 ptnow.Z = c(1, -1) ## Run allocation probability calculation prob = ZhaoNew_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, response = "Binary", omega = rep(0.25, 4), p = 0.8 ) ## View allocation probability for treatment A probset.seed(123) ptsb.X = sample(c(1, -1), 400, replace = TRUE) ptsb.Z = cbind( sample(c(1, -1), 400, replace = TRUE), sample(c(1, -1), 400, replace = TRUE) ) ptsb.Y = sample(c(1, 0), 400, replace = TRUE) ptsb.t = sample(c(1, 0), 400, replace = TRUE) ## Incoming patient ptnow.X = 1 ptnow.Z = c(1, -1) ## Run allocation probability calculation prob = ZhaoNew_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, response = "Binary", omega = rep(0.25, 4), p = 0.8 ) ## View allocation probability for treatment A prob
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 Zhao's New procedure for survival trials.
ZhaoNew_Alloc_Surv( ptsb.X, ptsb.Z, ptsb.t, ptsb.Y, ptsb.E, ptnow.X, ptnow.Z, omega, p = 0.8 )ZhaoNew_Alloc_Surv( ptsb.X, ptsb.Z, ptsb.t, ptsb.Y, ptsb.E, ptnow.X, ptnow.Z, omega, p = 0.8 )
ptsb.X |
a vector of length |
ptsb.Z |
a |
ptsb.t |
a vector of length |
ptsb.Y |
a vector of length |
ptsb.E |
a vector of length |
ptnow.X |
a binary value of the predictive covariate of the present patient. |
ptnow.Z |
a vector of length |
omega |
a vector of length |
p |
a positive value between 0.75 and 0.95. The probability parameter of Efron's biased coin design. |
prob |
Probability of assigning the upcoming patient to treatment A. |
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 = rexp(400, rate = 1) # survival time (response) ptsb.E = sample(c(1, 0), 400, replace = TRUE) # event indicator (1 = event, 0 = censored) ptsb.t = sample(c(1, 0), 400, replace = TRUE) # treatment assignment # Incoming patient covariates ptnow.X = 1 ptnow.Z = c(1, -1) # Allocation probability calculation prob = ZhaoNew_Alloc_Surv( ptsb.X = ptsb.X, ptsb.Z = ptsb.Z, ptsb.Y = ptsb.Y, ptsb.E = ptsb.E, ptsb.t = ptsb.t, ptnow.X = ptnow.X, ptnow.Z = ptnow.Z, omega = rep(0.25, 4), p = 0.8 ) # View the allocation probability for treatment A probset.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 = rexp(400, rate = 1) # survival time (response) ptsb.E = sample(c(1, 0), 400, replace = TRUE) # event indicator (1 = event, 0 = censored) ptsb.t = sample(c(1, 0), 400, replace = TRUE) # treatment assignment # Incoming patient covariates ptnow.X = 1 ptnow.Z = c(1, -1) # Allocation probability calculation prob = ZhaoNew_Alloc_Surv( ptsb.X = ptsb.X, ptsb.Z = ptsb.Z, ptsb.Y = ptsb.Y, ptsb.E = ptsb.E, ptsb.t = ptsb.t, ptnow.X = ptnow.X, ptnow.Z = ptnow.Z, omega = rep(0.25, 4), p = 0.8 ) # View the allocation probability for treatment A prob
This function simulates a trial using Zhao's new design for binary and continuous responses.
ZhaoNew_Sim( n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, response, omega, p = 0.8 )ZhaoNew_Sim( n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, response, omega, p = 0.8 )
n |
a positive integer. The sample size of the simulated data. |
mu |
a vector of length 2. The true parameters of treatment. |
beta |
a vector of length 2. The true parameters of predictive covariate and interaction with treatment. |
gamma |
a vector of length k. The true parameters of prognostic covariates. |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally to both treatments. |
pts.X |
a vector of length n. The vector of patients' binary predictive covariates. |
pts.Z |
a matrix of |
response |
the type of the response. Options are |
omega |
a vector of length |
p |
a positive value between 0.75 and 0.95. The probability parameter of Efron's biased coin design. |
method |
The name of procedure. |
sampleSize |
The sample size of the trial. |
assignment |
The randomization sequence. |
X1proportion |
Average allocation proportion for treatment A when predictive covariate equals the smaller value. |
X2proportion |
Average allocation proportion for treatment A when predictive covariate equals the larger value. |
proportion |
Average allocation proportion for treatment A. |
failureRate |
Proportion of treatment failures (if |
meanResponse |
Mean response value (if |
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) # Simulation settings n = 400 # total number of patients m0 = 40 # initial burn-in sample size mu = c(0.5, 0.8) # potential means (for continuous or logistic link) beta = c(1, 1) # treatment effect and predictive covariate effect gamma = c(0.1, 0.5) # prognostic covariate effects omega = rep(0.25, 4) # imbalance weights p = 0.8 # biased coin probability # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run the simulation (binary response setting) result = ZhaoNew_Sim( n = n, mu = mu, beta = beta, gamma = gamma, m0 = m0, pts.X = pts.X, pts.Z = pts.Z, response = "Binary", omega = omega, p = p )set.seed(123) # Simulation settings n = 400 # total number of patients m0 = 40 # initial burn-in sample size mu = c(0.5, 0.8) # potential means (for continuous or logistic link) beta = c(1, 1) # treatment effect and predictive covariate effect gamma = c(0.1, 0.5) # prognostic covariate effects omega = rep(0.25, 4) # imbalance weights p = 0.8 # biased coin probability # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run the simulation (binary response setting) result = ZhaoNew_Sim( n = n, mu = mu, beta = beta, gamma = gamma, m0 = m0, pts.X = pts.X, pts.Z = pts.Z, response = "Binary", omega = omega, p = p )
This function simulates a clinical trial using Zhao's New design for survival responses.
ZhaoNew_Sim_Surv( n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, censor.time, arrival.rate, omega, p = 0.8 )ZhaoNew_Sim_Surv( n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, censor.time, arrival.rate, omega, p = 0.8 )
n |
a positive integer. The sample size of the simulated data. |
mu |
a number. The true parameters of treatment. |
beta |
a vector of length 2. The true parameters of predictive covariate and interaction with treatment. |
gamma |
a vector of length k. The true parameters of prognostic covariates. |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally to both treatments. |
pts.X |
a vector of length n. The vector of patients' binary predictive covariates.Must be binary. |
pts.Z |
a matrix of |
censor.time |
a positive number. The upper bound of the uniform censor time in year. |
arrival.rate |
a positive integer. The arrival rate of patients each year. |
omega |
a vector of length |
p |
a positive value between 0.75 and 0.95. The probability parameter of Efron's biased coin design. |
A list with the following elements:
method |
The name of procedure. |
sampleSize |
The sample size of the trial. |
assignment |
The randomization sequence. |
X1proportion |
Average allocation proportion for treatment A when predictive covariate equals the smaller value. |
X2proportion |
Average allocation proportion for treatment A when predictive covariate equals the larger value. |
proportion |
Average allocation proportion for treatment A. |
N.events |
Total number of events occured of the trial. |
responses |
Observed survival responses of patients. |
events |
Survival status vector of patients(1=event,0=censored) |
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123) # Simulation settings n = 400 # total number of patients m0 = 40 # initial burn-in sample size mu = 0.5 # potential means (for continuous or logistic link) beta = c(1, 1) # treatment effect and predictive covariate effect gamma = c(0.1, 0.5) # prognostic covariate effects omega = rep(0.25, 4) # imbalance weights p = 0.8 # biased coin probability censor.time = 2 # maximum censoring time arrival.rate = 150 # arrival rate of patients # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run the simulation (binary response setting) result = ZhaoNew_Sim_Surv( n = n, mu = mu, beta = beta, gamma = gamma, m0 = m0, pts.X = pts.X, pts.Z = pts.Z, omega = omega, p = p, censor.time = censor.time, arrival.rate = arrival.rate )set.seed(123) # Simulation settings n = 400 # total number of patients m0 = 40 # initial burn-in sample size mu = 0.5 # potential means (for continuous or logistic link) beta = c(1, 1) # treatment effect and predictive covariate effect gamma = c(0.1, 0.5) # prognostic covariate effects omega = rep(0.25, 4) # imbalance weights p = 0.8 # biased coin probability censor.time = 2 # maximum censoring time arrival.rate = 150 # arrival rate of patients # Generate patient covariates pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate pts.Z = cbind( sample(c(1, -1), n, replace = TRUE), # prognostic Z1 sample(c(1, -1), n, replace = TRUE) # prognostic Z2 ) # Run the simulation (binary response setting) result = ZhaoNew_Sim_Surv( n = n, mu = mu, beta = beta, gamma = gamma, m0 = m0, pts.X = pts.X, pts.Z = pts.Z, omega = omega, p = p, censor.time = censor.time, arrival.rate = arrival.rate )