Title: | Implement Covariate-Adaptive Randomization |
---|---|
Description: | Implementing seven Covariate-Adaptive Randomization to assign patients to two treatments. Three of these procedures can also accommodate quantitative and mixed covariates. Given a set of covariates, the user can generate a single sequence of allocations or replicate the design multiple times by simulating the patients' covariate profiles. At the end, an extensive assessment of the performance of the randomization procedures is provided, calculating several imbalance measures. See Baldi Antognini A, Frieri R, Zagoraiou M and Novelli M (2022) <doi:10.1007/s00362-022-01381-1> for details. |
Authors: | Rosamarie Frieri [aut, cre], Marco Novelli [aut] |
Maintainer: | Rosamarie Frieri <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.1 |
Built: | 2024-10-31 20:32:08 UTC |
Source: | CRAN |
Implementing seven Covariate-Adaptive Randomization to assign patients to two treatments. Three of these procedures can also accommodate quantitative and mixed covariates. Given a set of covariates, the user can generate a single sequence of allocations or replicate the design multiple times by simulating the patients' covariate profiles. At the end, an extensive assessment of the performance of the randomization procedures is provided, calculating several imbalance measures.
This work was supported by the EU funding within the NextGenerationEU PRIN2022 Optimal and adaptive designs for modern medical experimentation (2022TRB44L).
R. Frieri [email protected], M. Novelli [email protected]
Atkinson A C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
Baldi Antognini A, Frieri R, Zagoraiou M, Novelli M. The Efficient Covariate-Adaptive Design for high-order balancing of quantitative and qualitative covariates. Statistical Papers, 2022.
Baldi Antognini A and Zagoraiou M. The covariate-adaptive biased coin design for balancing clinical trials in the presence of prognostic factors. Biometrika, 2011, 98(3): 519-535.
Efron B, Forcing a sequential experiment to be balanced. Biometrika, 1971, 58(3): 403-418.
Hu Y, Hu F. Asymptotic properties of covariate-adaptive randomization. The Annals of Statistics, 2012, 40(3): 1974-1815.
Ma Z and Hu F. Balancing continuous covariates based on Kernel densities. Contemporary Clinical Trials, 2013, 34(2): 262-269.
Pocock S J, Simon R. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. Biometrics, 1975, 31(1): 103-115.
Soares F, Wu CFJ. Some restricted randomization rules in sequential designs. Communications in Statistics Theory and Methods 1983, 12: 2017-2034.
CABCD, HuHu, PocSim, BSD, DABCD, ECADE, KER.
Implements the Big Stick Design by Soares and Wu (1963) for assigning patients to two treatments A and B. The procedure works with qualitative covariates only.
BSD(data, bound = 3, print.results = TRUE)
BSD(data, bound = 3, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
bound |
integer parameter representing the maximum tolerated imbalance. The default value is set to 3. |
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B with the Big Stick Design as described in Soares and Wu (1983).
The argument bound
is the maximum tolerated imbalance that the experiment can accept: complete randomization is used as long as the imbalance of the treatment allocation does not exceed bound
. When the imbalance reaches the value set in bound
, a deterministic assignment is made to lower the imbalance.
At the end of the study the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B. The strata imbalances measures report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within-stratum imbalance (D.strata
), calculated as 2*A.strata
-N.strata
. The within-covariate imbalances report, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B. See also Value.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end of the
study ( |
Strata.measures |
a data frame containing for each possiblue stratum the
corresponding imbalances:
|
Imbalances |
a list containing all the imbalance measures:
|
data |
the data provided in input. |
observed.strata |
a data frame with all the observed strata. |
Soares F, Wu CFJ. Some restricted randomization rules in sequential designs. Communications in Statistics Theory and Methods 1963, 12: 2017-2034.
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
See Also as BSD.sim
for allocating patients by simulating their covariate profiles.
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design BSD(data = df1, bound = 3, print.results = TRUE) # To view a summary and create a list containing all the metrics of the design res <- BSD(data = df1, bound = 3, print.results = TRUE) res
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design BSD(data = df1, bound = 3, print.results = TRUE) # To view a summary and create a list containing all the metrics of the design res <- BSD(data = df1, bound = 3, print.results = TRUE) res
Implements the Big Stick Design by Soares and Wu (1963) for assigning patients to two treatments A and B by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative covariates only.
#With existing dataframe BSD.sim(data, covar = NULL, n = NULL, bound = 3, nrep = 1000, print.results = TRUE) #With covariates BSD.sim(data = NULL, covar, n, bound = 3, nrep = 1000, print.results = TRUE)
#With existing dataframe BSD.sim(data, covar = NULL, n = NULL, bound = 3, nrep = 1000, print.results = TRUE) #With covariates BSD.sim(data = NULL, covar, n, bound = 3, nrep = 1000, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
covar |
either a vector or a list to be specified only if |
n |
number of patients (to be specified only if |
bound |
integer parameter representing the maximum tolerated imbalance. The default value is set to 3. |
nrep |
number of trial replications. |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the Big Stick Design by Soares and Wu (1983) (see BSD
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covar
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications. See also BSD
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial:
|
out |
For each replication returns a list of the data provided in input ( |
Soares F, Wu CFJ. Some restricted randomization rules in sequential designs. Communications in Statistics Theory and Methods 1963, 12: 2017-2034.
See Also BSD
.
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res1 <- BSD.sim(data = df1, covar = NULL, n = NULL, bound = 3, nrep = 100, print.results = TRUE) ### With covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- BSD.sim(data = NULL, covar = c(2,2,3), n = 100, bound = 3, nrep = 100, print.results = TRUE)
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res1 <- BSD.sim(data = df1, covar = NULL, n = NULL, bound = 3, nrep = 100, print.results = TRUE) ### With covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- BSD.sim(data = NULL, covar = c(2,2,3), n = 100, bound = 3, nrep = 100, print.results = TRUE)
Implements the Covariate-adjusted Biased Coin Design by Baldi Antognini and Zagoraiou (2011), a stratified randomization procedure for two treatments A and B. The procedure works with qualitative covariates only.
CABCD(data, a = 3, print.results = TRUE)
CABCD(data, a = 3, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
a |
(non-negative) design parameter determining the degree of randomness: |
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B as described in Baldi Antognini and Zagoraiou (2011).
The parameter a
determines the degree of randomness of the procedure.
At the end of the study, the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B. The strata imbalances measures report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within-stratum imbalance (D.strata
), calculated as 2*A.strata
-N.strata
. The within-covariate imbalances report, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B. See also Value.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end of the
study ( |
Strata.measures |
a data frame containing for each possiblue stratum the corresponding
imbalances:
|
Imbalances |
a list containing all the imbalance measures:
|
data |
the data provided in input. |
observed.strata |
a data frame with all the observed strata. |
Baldi Antognini A and Zagoraiou M. The covariate-adaptive biased coin design for balancing clinical trials in the presence of prognostic factors. Biometrika, 2011, 98(3): 519-535.
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
CABCD.sim
for allocating patients by simulating their covariate profiles.
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design CABCD(data = df1, a = 3) # To view a summary # and create a list containing all the metrics of the design res <- CABCD(data = df1, a = 3) res
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design CABCD(data = df1, a = 3) # To view a summary # and create a list containing all the metrics of the design res <- CABCD(data = df1, a = 3) res
Implements the Covariate-adjusted Biased Coin Design by Baldi Antognini and Zagoraiou (2011) by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative covariates only.
#With existing dataframe CABCD.sim(data, covar = NULL, n = NULL, a = 3, nrep = 1000, print.results = TRUE) #With covariates CABCD.sim(data = NULL, covar, n, a = 3, nrep = 1000, print.results = TRUE)
#With existing dataframe CABCD.sim(data, covar = NULL, n = NULL, a = 3, nrep = 1000, print.results = TRUE) #With covariates CABCD.sim(data = NULL, covar, n, a = 3, nrep = 1000, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
covar |
either a vector or a list to be specified only if |
n |
number of patients (to be specified only if |
a |
(non-negative) design parameter determining the degree of randomness:
|
nrep |
number of trial replications. |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the Covariate-Adjusted Biased Coin Design (see CABCD
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covat
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications. See also CABCD
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial:
|
out |
For each replication returns a list of the data provided in input ( |
Baldi Antognini A and Zagoraiou M. The covariate-adaptive biased coin design for balancing clinical trials in the presence of prognostic factors. Biometrika, 2011, 98(3): 519-535.
See Also CABCD
.
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res1 <- CABCD.sim(data = df1, n = NULL, a = 3, nrep = 100) ### With covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- CABCD.sim(covar = c(2,2,3), n = 100, a = 3, nrep = 100)
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res1 <- CABCD.sim(data = df1, n = NULL, a = 3, nrep = 100) ### With covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- CABCD.sim(covar = c(2,2,3), n = 100, a = 3, nrep = 100)
-optimum biased coin designImplements the -optimum BCD by A. Atkinson (1982) for assigning patients to two treatments A and B in order to minimize the variance of the estimated treatment difference sequentially. The procedure works with qualitative and quantitative covariates.
DABCD(data, all.cat, print.results = TRUE)
DABCD(data, all.cat, print.results = TRUE)
data |
a data frame or a matrix. It can be a matrix only when |
all.cat |
logical. If all the covariates in |
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B with the -optimum BCD as described in Atkinson (1982).
This randomization procedure can be used when data
contains only qualitative covariate, in this case set all.cat = TRUE
, when data
contains only quantitative covariates or when covariates of mixed nature are present, in these two latter cases set all.cat = FALSE
. The function's output is slighly different according to these three scenarios as described in Value.
At the end of the study the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B.
Only when all.cat = TRUE
, the function returns the strata imbalances measures, that report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within-stratum imbalance (D.strata
), calculated as 2*A.strata
-N.strata
.
If at least one qualitative covariate is present, the function returns the within-covariate imbalances reporting, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B.
If at least one quantitative covariate is present, the function returns the difference in means. For each quantitative covariate, is reported the difference in the mean in group A and B.
See Value for more details.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end
of the study ( |
Strata.measures |
(only if |
Imbalances |
a list containing all the imbalance measures.
|
data |
the data provided in input. |
diff_mean |
(only if |
observed.strata |
(only if |
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
See Also as DABCD.sim
to for allocating patients by simulating their covariate profiles.
require(covadap) ### Implement with qualitative covariates (set all.cat = TRUE) # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design DABCD(data = df1, all.cat = TRUE, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res1 <- DABCD(data = df1, all.cat = TRUE, print.results = TRUE) res1 ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design DABCD(data = ff1[,5:6], all.cat = FALSE, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res2 <- DABCD(data = ff1[,5:6], all.cat = FALSE, print.results = TRUE) res2 ### With mixed covariates (set all.cat = FALSE) # To just view a summary of the metrics of the design DABCD(data = ff1, all.cat = FALSE, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res3 <- DABCD(data = ff1, all.cat = FALSE, print.results = TRUE) res3
require(covadap) ### Implement with qualitative covariates (set all.cat = TRUE) # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design DABCD(data = df1, all.cat = TRUE, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res1 <- DABCD(data = df1, all.cat = TRUE, print.results = TRUE) res1 ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design DABCD(data = ff1[,5:6], all.cat = FALSE, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res2 <- DABCD(data = ff1[,5:6], all.cat = FALSE, print.results = TRUE) res2 ### With mixed covariates (set all.cat = FALSE) # To just view a summary of the metrics of the design DABCD(data = ff1, all.cat = FALSE, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res3 <- DABCD(data = ff1, all.cat = FALSE, print.results = TRUE) res3
-optimum biased coin designImplements the -optimum biased coin design BCD by A. Atkinson (1982) for assigning patients to two treatments A and B in order to minimize the variance of the estimated treatment difference sequentially by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative and quantitative covariates.
#With existing dataframe provided in data DABCD.sim(data, covar = NULL, n = NULL, all.cat, nrep = 1000, print.results = TRUE) #With covariates DABCD.sim(data = NULL, covar, n, all.cat, nrep = 1000, print.results = TRUE)
#With existing dataframe provided in data DABCD.sim(data, covar = NULL, n = NULL, all.cat, nrep = 1000, print.results = TRUE) #With covariates DABCD.sim(data = NULL, covar, n, all.cat, nrep = 1000, print.results = TRUE)
data |
a data frame or a matrix. It can be a matrix only when |
covar |
either a vector or a list to be specified only if |
n |
number of patients (to be specified only if |
all.cat |
logical. If all the covariates in |
nrep |
number of trial replication. |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the -optimum BCD by Atkinson (see
DABCD
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covar
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications according to the nature of the covariates. See also DABCD
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial
|
out |
For each replication returns a list of the data provided in input ( |
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
See Also as DABCD
.
require(covadap) # Here we set nrep = 50 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### Implement with qualitative covariates (set all.cat = TRUE) #### With an existing dataset # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design DABCD.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res1 <- DABCD.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, nrep = 50) #### By specifying the covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- DABCD.sim(data = NULL, covar = c(2,3,3), n = 100, all.cat = TRUE, nrep = 50) ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) #### With an existing dataset # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design DABCD.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res3 <- DABCD.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) #### By specifying the covariates # e.g. 2 quantitative covariates: # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res4 <- DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50) ### With mixed covariates (set all.cat = FALSE) #### With an existing dataset # To just view a summary of the metrics of the design DABCD.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res5 <- DABCD.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) #### By specifying the covariates # e.g. one qualitative covariate and 2 quantitative covariates: # gender with levels M and F # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(cat = list(gender = c("M", "F")), quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) #To just view a summary of the metrics of the design DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res6 <- DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50)
require(covadap) # Here we set nrep = 50 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### Implement with qualitative covariates (set all.cat = TRUE) #### With an existing dataset # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design DABCD.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res1 <- DABCD.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, nrep = 50) #### By specifying the covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- DABCD.sim(data = NULL, covar = c(2,3,3), n = 100, all.cat = TRUE, nrep = 50) ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) #### With an existing dataset # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design DABCD.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res3 <- DABCD.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) #### By specifying the covariates # e.g. 2 quantitative covariates: # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res4 <- DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50) ### With mixed covariates (set all.cat = FALSE) #### With an existing dataset # To just view a summary of the metrics of the design DABCD.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res5 <- DABCD.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, nrep = 50) #### By specifying the covariates # e.g. one qualitative covariate and 2 quantitative covariates: # gender with levels M and F # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(cat = list(gender = c("M", "F")), quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) #To just view a summary of the metrics of the design DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res6 <- DABCD.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, nrep = 50)
Implements the Efficient Covariate-Adaptive DEsign by Baldi Antognini et al. (2022) for assigning patients to two treatments A and B. The procedure works with qualitative and quantitative covariates.
ECADE(data, all.cat, rho = 0.85, alloc.function = "Efron", print.results = TRUE)
ECADE(data, all.cat, rho = 0.85, alloc.function = "Efron", print.results = TRUE)
data |
a data frame or a matrix. It can be a matrix only when |
all.cat |
logical. If all the covariates in |
rho |
biasing probability, to be used only with the Efron allocation function
( |
alloc.function |
a character specifying the allocation function used in
the randomization procedure:
|
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B with the Efficient Covariate-Adaptive Design as described in Baldi Antognini et al. (2022).
This randomization procedure can be used when data
contains only qualitative covariate, in this case set all.cat = TRUE
, when data
contains only quantitative covariates or when covariates of mixed nature are present, in these two latter cases set all.cat = FALSE
. The function's output is slighly different according to these three scenarios as described in Value.
The assignment probability to A of each patient is based on the Efron's allocation function (Efron, 1971) with biasing probability equal to rho
if alloc.function = "Efron"
. Otherwise the allocation ptobability to A is based on the cumulative distribution function of the standard normal distribution (see Arguments).
At the end of the study the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B.
Only when all.cat = TRUE
, the function returns the strata imbalances measures, that report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within-stratum imbalance (D.strata
), calculated as 2*A.strata-N.strata
.
If at least one qualitative covariate is present, the function returns the within-covariate imbalances reporting, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B.
If at least one quantitative covariate is present, the function returns the difference in means. For each quantitative covariate, is reported the difference in the mean in group A and B.
See Value for more details.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end
of the study ( |
Strata.measures |
(only if |
Imbalances |
a list containing all the imbalance measures.
|
data |
the data provided in input. |
diff_mean |
(only if |
observed.strata |
(only if |
Baldi Antognini A, Frieri R, Zagoraiou M, Novelli M. The Efficient Covariate-Adaptive Design for high-order balancing of quantitative and qualitative covariates. Statistical Papers, 2022.
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
Efron B, Forcing a sequential experiment to be balanced. Biometrika, 1971, 58(3): 403-418.
See Also as ECADE.sim
for allocating patients by simulating their covariate profiles.
require(covadap) # Assume we choose Efron's allocation function with rho = 0.85 ### Implement with qualitative covariates (set all.cat = TRUE) # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design ECADE(data = df1, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res1 <- ECADE(data = df1, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) res1 ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design ECADE(data = ff1[,5:6], all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res2 <- ECADE(data = ff1[,5:6], all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) res2 ### With mixed covariates (set all.cat = FALSE) # To just view a summary of the metrics of the design ECADE(data = ff1, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res3 <- ECADE(data = ff1, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) res3
require(covadap) # Assume we choose Efron's allocation function with rho = 0.85 ### Implement with qualitative covariates (set all.cat = TRUE) # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design ECADE(data = df1, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res1 <- ECADE(data = df1, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) res1 ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design ECADE(data = ff1[,5:6], all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res2 <- ECADE(data = ff1[,5:6], all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) res2 ### With mixed covariates (set all.cat = FALSE) # To just view a summary of the metrics of the design ECADE(data = ff1, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res3 <- ECADE(data = ff1, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, print.results = TRUE) res3
Implements the Efficient Covariate-Adaptive DEsign by Baldi Antognini et al. (2022) for assigning patients to two treatments A and B by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative and quantitative covariates.
#With existing dataframe provided in data ECADE.sim(data, covar = NULL, n = NULL, all.cat, nrep = 1000, rho = 0.85, alloc.function = "Efron", print.results = TRUE) #With covariates ECADE.sim(data = NULL, covar, n, all.cat, nrep = 1000, rho = 0.85, alloc.function = "Efron", print.results = TRUE)
#With existing dataframe provided in data ECADE.sim(data, covar = NULL, n = NULL, all.cat, nrep = 1000, rho = 0.85, alloc.function = "Efron", print.results = TRUE) #With covariates ECADE.sim(data = NULL, covar, n, all.cat, nrep = 1000, rho = 0.85, alloc.function = "Efron", print.results = TRUE)
data |
a data frame or a matrix. It can be a matrix only when |
covar |
either a vector or a list to be specified only if |
n |
number of patients (to be specified only if |
all.cat |
logical. If all the covariates in |
nrep |
number of trial replications. |
rho |
biasing probability, to be used only with the Efron allocation function
( |
alloc.function |
a character specifying the allocation function
used in the randomization procedure: |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the Efficient Covariate-Adaptive Design as described in Baldi Antognini et al. (see ECADE
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covar
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications according to the nature of the covariates. See also ECADE
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial
|
out |
For each replication returns a list of the data provided in input ( |
Baldi Antognini A, Frieri R, Zagoraiou M, Novelli M. The Efficient Covariate-Adaptive Design for high-order balancing of quantitative and qualitative covariates. Statistical Papers, 2022.
See Also ECADE
.
require(covadap) # Here we set nrep = 50 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### Implement with qualitative covariates (set all.cat = TRUE) #### With an existing dataset # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design ECADE.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res1 <- ECADE.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 50) #### By specifying the covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- ECADE.sim(data = NULL, covar = c(2,3,3), n = 100, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 50) ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) #### With an existing dataset # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design ECADE.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary and create a list containing all the metrics of the design res3 <- ECADE.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) #### By specifying the covariates # e.g. 2 quantitative covariates: # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res4 <- ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) ### With mixed covariates (set all.cat = FALSE) #### With an existing dataset # To just view a summary of the metrics of the design ECADE.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res5 <- ECADE.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) #### By specifying the covariates # e.g. one qualitative covariate and 2 quantitative covariates: # gender with levels M and F # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(cat = list(gender = c("M", "F")), quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary and # create a list containing all the metrics of the design res6 <- ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50)
require(covadap) # Here we set nrep = 50 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### Implement with qualitative covariates (set all.cat = TRUE) #### With an existing dataset # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design ECADE.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res1 <- ECADE.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 50) #### By specifying the covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- ECADE.sim(data = NULL, covar = c(2,3,3), n = 100, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 50) ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) #### With an existing dataset # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design ECADE.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary and create a list containing all the metrics of the design res3 <- ECADE.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) #### By specifying the covariates # e.g. 2 quantitative covariates: # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res4 <- ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) ### With mixed covariates (set all.cat = FALSE) #### With an existing dataset # To just view a summary of the metrics of the design ECADE.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res5 <- ECADE.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) #### By specifying the covariates # e.g. one qualitative covariate and 2 quantitative covariates: # gender with levels M and F # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(cat = list(gender = c("M", "F")), quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50) # To view a summary and # create a list containing all the metrics of the design res6 <- ECADE.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, alloc.function = "Efron", rho = 0.85, nrep = 50)
Implements the Covariate-Adaptive randomization by Hu and Hu (2012) for assigning patients to two treatments A and B. The procedure works with qualitative covariates only.
HuHu(data, p = 0.85, omega = NULL, print.results = TRUE)
HuHu(data, p = 0.85, omega = NULL, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
p |
biased coin probability for the Efron's allocation function ( |
omega |
vector of weights for the overall, within-stratum, and within-covariate-margin levels. If |
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B as described in Hu and Hu (2012).
The assignment probability to A of each patient is based on the Efron's allocation function (Efron, 1971) with biasing probability equal to p
.
At the end of the study the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B. The strata imbalances measures report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within stratum imbalance (D.strata
), calculated as 2*A.strata
-N.strata
. The within covariate imbalances report, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B. See also Value.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end of the
study ( |
Strata.measures |
a data frame containing for each possiblue stratum the
corresponding imbalances:
|
Imbalances |
a list containing all the imbalance measures:
|
data |
the data provided in input. |
observed.strata |
a data frame with all the observed strata. |
Hu Y, Hu F. Asymptotic properties of covariate-adaptive randomization. The Annals of Statistics, 2012, 40(3): 1794-1815.
Efron B, Forcing a sequential experiment to be balanced. Biometrika, 1971, 58(3): 403-418.
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
HuHu.sim
for allocating patients by simulating their covariate profiles.
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 200, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 200, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 200, TRUE), stringsAsFactors = TRUE) # To view a summary of the metrics of the design HuHu(df1, p = 0.85, omega = NULL, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res <- HuHu(df1, p = 0.85, omega = NULL, print.results = TRUE) res
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 200, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 200, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 200, TRUE), stringsAsFactors = TRUE) # To view a summary of the metrics of the design HuHu(df1, p = 0.85, omega = NULL, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res <- HuHu(df1, p = 0.85, omega = NULL, print.results = TRUE) res
Implements the Covariate-Adaptive randomization by Hu and Hu (2012) for assigning patients to two treatments A and B by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative covariates only.
#With existing dataframe HuHu.sim(data, covar = NULL, n = NULL, p = 0.85, omega = NULL, nrep = 1000, print.results = TRUE) #With covariates HuHu.sim(data = NULL, covar, n, p = 0.85, omega = NULL, nrep = 1000, print.results = TRUE)
#With existing dataframe HuHu.sim(data, covar = NULL, n = NULL, p = 0.85, omega = NULL, nrep = 1000, print.results = TRUE) #With covariates HuHu.sim(data = NULL, covar, n, p = 0.85, omega = NULL, nrep = 1000, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
covar |
either a vector or a list to be specified only if |
n |
number of patients (to be specified only if |
p |
biased coin probability for the Efron's allocation function ( |
omega |
vector of weights for the overall, within-stratum, and within-covariate-margin levels. If |
nrep |
number of trial replications. |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the Covariate-Adaptive randomization procedure proposed by Hu and Hu (see HuHu
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covar
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications. See also HuHu
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial:
|
out |
For each replication returns a list of the data provided in input ( |
Hu Y, Hu F. Asymptotic properties of covariate-adaptive randomization. The Annals of Statistics, 2012, 40(3): 1794-1815.
See Also HuHu
.
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res2 <- HuHu.sim(data = df1, covar = NULL, n = NULL, p = 0.85, omega = NULL, nrep = 100) ### With covariate # e.g. two binary covariates and one with three levels and 100 patients res2 <- HuHu.sim(data = NULL, covar = c(2,2,3), n = 100, p = 0.85, omega = NULL, nrep = 100)
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res2 <- HuHu.sim(data = df1, covar = NULL, n = NULL, p = 0.85, omega = NULL, nrep = 100) ### With covariate # e.g. two binary covariates and one with three levels and 100 patients res2 <- HuHu.sim(data = NULL, covar = c(2,2,3), n = 100, p = 0.85, omega = NULL, nrep = 100)
Implements the Covariate-Adaptive randomization by Ma and Hu (2013) for assigning patients to two treatments A and B in order to minimize the distance between the covariate distribution in the two treatment groups. The procedure works with qualitative and quantitative covariates.
KER(data, all.cat, p = 0.8, print.results = TRUE)
KER(data, all.cat, p = 0.8, print.results = TRUE)
data |
a data frame or a matrix. It can be a matrix only when |
all.cat |
logical. If all the covariates in |
p |
biasing probability for the Efron's allocation function ( |
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B with the Covariate-Adaptive randomization based on kernel density estimation as described in Ma and Hu (2013).
This randomization procedure can be used when data
contains only qualitative covariate, in this case set all.cat = TRUE
, when data
contains only quantitative covariates or when covariates of mixed nature are present, in these two latter cases set all.cat = FALSE
. The function's output is slighly different according to these three scenarios as described in Value.
The assignment probability to A of each patient is based on the Efron's allocation function (Efron, 1971) with biasing probability equal to p
.
At the end of the study the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B.
Only when all.cat = TRUE
, the function returns the strata imbalances measures, that report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within-stratum imbalance (D.strata
), calculated as 2*A.strata-N.strata
.
If at least one qualitative covariate is present, the function returns the within-covariate imbalances reporting, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B.
If at least one quantitative covariate is present, the function returns the difference in means. For each quantitative covariate, is reported the difference in the mean in group A and B.
See Value for more details.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end
of the study ( |
Strata.measures |
(only if |
Imbalances |
a list containing all the imbalance measures.
|
data |
the data provided in input. |
diff_mean |
(only if |
observed.strata |
(only if |
Ma Z and Hu F. Balancing continuous covariates based on Kernel densities. Contemporary Clinical Trials, 2013, 34(2): 262-269.
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
Efron B, Forcing a sequential experiment to be balanced. Biometrika, 1971, 58(3): 403-418.
See Also as KER.sim
for allocating patients by simulating their covariate profiles.
require(covadap) ### Implement with qualitative covariates (set all.cat = TRUE) # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design KER(data = df1, all.cat = TRUE, p = 0.8, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res1 <- KER(data = df1, all.cat = TRUE, p = 0.8, print.results = TRUE) res1 ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design KER(data = ff1[,5:6], all.cat = FALSE, p = 0.8, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res2 <- KER(data = ff1[,5:6], p = 0.8, all.cat = FALSE, print.results = TRUE) res2 ### With mixed covariates # In this case the user must set all.cat = FALSE # To just view a summary of the metrics of the design KER(data = ff1, all.cat = FALSE, p = 0.8, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res3 <- KER(data = ff1, all.cat = FALSE, p = 0.8, print.results = TRUE) res3
require(covadap) ### Implement with qualitative covariates (set all.cat = TRUE) # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design KER(data = df1, all.cat = TRUE, p = 0.8, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res1 <- KER(data = df1, all.cat = TRUE, p = 0.8, print.results = TRUE) res1 ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design KER(data = ff1[,5:6], all.cat = FALSE, p = 0.8, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res2 <- KER(data = ff1[,5:6], p = 0.8, all.cat = FALSE, print.results = TRUE) res2 ### With mixed covariates # In this case the user must set all.cat = FALSE # To just view a summary of the metrics of the design KER(data = ff1, all.cat = FALSE, p = 0.8, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res3 <- KER(data = ff1, all.cat = FALSE, p = 0.8, print.results = TRUE) res3
Implements the Covariate-Adaptive randomization by Ma and Hu (2013) for assigning patients to two treatments A and B in order to minimize the distance between the covariate distribution in the two treatment groups by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative and quantitative covariates.
#With existing dataframe KER.sim(data, covar = NULL, n = NULL, all.cat, nrep = 1000, p = 0.8, print.results = TRUE) #With covariates KER.sim(data = NULL, covar, n, all.cat, nrep = 1000, p = 0.8, print.results = TRUE)
#With existing dataframe KER.sim(data, covar = NULL, n = NULL, all.cat, nrep = 1000, p = 0.8, print.results = TRUE) #With covariates KER.sim(data = NULL, covar, n, all.cat, nrep = 1000, p = 0.8, print.results = TRUE)
data |
a data frame or a matrix. It can be a matrix only when |
covar |
either a vector or a list to be specified only if |
n |
number of patients. |
all.cat |
logical. If all the covariates in |
nrep |
number of trial replications. |
p |
biasing probability for the Efron allocation function ( |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the Efficient Covariate-Adaptive Design as described in Ma and Hu (see KER
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covar
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications according to the nature of the covariates. See also KER
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial
|
out |
For each replication returns a list of the data provided in input ( |
Ma Z and Hu F. Balancing continuous covariates based on Kernel densities. Contemporary Clinical Trials, 2013, 34(2): 262-269.
See Also as KER
.
require(covadap) # Here we set nrep = 50 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### Implement with qualitative covariates (set all.cat = TRUE) #### With an existing dataset # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design KER.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res1 <- KER.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, p = 0.8, nrep = 50) #### By specifying the covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- KER.sim(data = NULL, covar = c(2,3,3), n = 100, all.cat = TRUE, p = 0.8, nrep = 50) ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) #### With an existing dataset # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design KER.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res3 <- KER.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) #### By specifying the covariates # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res4 <- KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50) ### With mixed covariates (set all.cat = FALSE) #### With an existing dataset # To just view a summary of the metrics of the design KER.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res5 <- KER.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) #### By specifying the covariates # e.g. one qualitative covariate and 2 quantitative covariates: # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 # gender with levels M and F covar = list(cat = list(gender = c("M", "F")), quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary and create a list containing all the metrics of the design res6 <- KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50)
require(covadap) # Here we set nrep = 50 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### Implement with qualitative covariates (set all.cat = TRUE) #### With an existing dataset # Create a sample dataset with qualitative covariates df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design KER.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res1 <- KER.sim(data = df1, covar = NULL, n = NULL, all.cat = TRUE, p = 0.8, nrep = 50) #### By specifying the covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- KER.sim(data = NULL, covar = c(2,3,3), n = 100, all.cat = TRUE, p = 0.8, nrep = 50) ### Implement with quantitative or mixed covariates # Create a sample dataset with covariates of mixed nature ff1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hypertension"), 10, TRUE), "smoke" = sample(c("yes", "no"), 100, TRUE, c(2 / 3, 1 / 3)), "cholesterol" = round(rnorm(100, 200, 8),1), "height" = rpois(100,160), stringsAsFactors = TRUE) ### With quantitative covariates only (set all.cat = FALSE) #### With an existing dataset # select only column 5 and 6 of the sample dataset # To just view a summary of the metrics of the design KER.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res3 <- KER.sim(data = ff1[,5:6], covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) #### By specifying the covariates # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 covar = list(quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res4 <- KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50) ### With mixed covariates (set all.cat = FALSE) #### With an existing dataset # To just view a summary of the metrics of the design KER.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary # and create a list containing all the metrics of the design res5 <- KER.sim(data = ff1, covar = NULL, n = NULL, all.cat = FALSE, p = 0.8, nrep = 50) #### By specifying the covariates # e.g. one qualitative covariate and 2 quantitative covariates: # BMI normally distributed with mean 26 and standard deviation 5 # cholesterol normally distributed with mean 200 and standard deviation 34 # gender with levels M and F covar = list(cat = list(gender = c("M", "F")), quant = list(BMI = c(26, 5), cholesterol = c(200, 34))) # To just view a summary of the metrics of the design KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50) # To view a summary and create a list containing all the metrics of the design res6 <- KER.sim(data = NULL, covar = covar, n = 100, all.cat = FALSE, p = 0.8, nrep = 50)
Implements the Pocock and Simon's minimization method by Pocock and Simon (1975) for assigning patients to two treatments A and B. The procedure works with qualitative covariates only.
PocSim(data, p = 0.85, print.results = TRUE)
PocSim(data, p = 0.85, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
p |
biased coin probability for the Efron's allocation function ( |
print.results |
logical. If TRUE a summary of the results is printed. |
The function assigns patients to treatments A or B as described in Pocock and Simon (1975).
The assignment probability to A of each patient is based on the Efron's allocation function (Efron, 1971) with biasing probability equal to p
.
At the end of the study the imbalance measures reported are the loss of estimation precision as described in Atkinson (1982), the Mahalanobis distance and the overall imbalance, defined as the difference in the total number of patients assigned to treatment A and B. The strata imbalances measures report, for each stratum, the total number of patients assigned (N.strata
), the number of patients assigned to A (A.strata
) and the within-stratum imbalance (D.strata
), calculated as 2*A.strata
-N.strata
. The within-covariate imbalances report, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B. See also Value.
It returns an object of class
"covadap"
, which is a list containing the following elements:
summary.info |
|
Assignments |
a vector with the treatment assignments. |
Imbalances.summary |
summary of overall imbalance measures at the end of the
study ( |
Strata.measures |
a data frame containing for each possiblue stratum the
corresponding imbalances:
|
Imbalances |
a list containing all the imbalance measures:
|
data |
the data provided in input. |
observed.strata |
a data frame with all the observed strata. |
Pocock S J, Simon R. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. Biometrics, 1975, 31(1): 103-115.
Efron B, Forcing a sequential experiment to be balanced. Biometrika, 1971, 58(3): 403-418.
Atkinson A. C. Optimum biased coin designs for sequential clinical trials with prognostic factors. Biometrika, 1982, 69(1): 61-67.
See Also as PocSim.sim
for allocating patients by simulating their covariate profiles.
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design PocSim(df1, p = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res <- PocSim(df1, p = 0.85, print.results = TRUE) res
require(covadap) # Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # To just view a summary of the metrics of the design PocSim(df1, p = 0.85, print.results = TRUE) # To view a summary # and create a list containing all the metrics of the design res <- PocSim(df1, p = 0.85, print.results = TRUE) res
Implements the Pocock and Simon's minimization method by Pocock and Simon (1975) for assigning patients to two treatments A and B by simulating the covariate profile of each patient using an existing dataset or specifying number and levels of the covariates. The procedure works with qualitative covariates only.
#With existing dataframe PocSim.sim(data, covar = NULL, n = NULL, p = 0.85, nrep = 1000, print.results = TRUE) #With covariates PocSim.sim(data = NULL, covar, n, p = 0.85, nrep = 1000, print.results = TRUE)
#With existing dataframe PocSim.sim(data, covar = NULL, n = NULL, p = 0.85, nrep = 1000, print.results = TRUE) #With covariates PocSim.sim(data = NULL, covar, n, p = 0.85, nrep = 1000, print.results = TRUE)
data |
a data frame or a matrix. Each row of |
covar |
either a vector or a list to be specified only if |
n |
number of patients (to be specified only if |
p |
biased coin probability for the Efron's allocation function ( |
nrep |
number of trial replications. |
print.results |
logical. If TRUE a summary of the results is printed. |
This function simulates nrep
times a clinical study assigning patients to treatments A and B with the minimization method by Pocock and Simon (see PocSim
).
When covar
is provided, the function finds all the possible combination of the levels of the covariates, i.e., the strata and, at each trial replication, the patients' covariate profiles are uniformly sampled within those strata. The specification of covar
requires the specification of the number of patients n
.
When data
is provided, at each trial replication, the patients' covariate profiles are sampled from the observed strata with uniform distribution. In this case the number of patients equals the number of rows of data
.
The summary printed when print.results = TRUE
reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications. See also PocSim
.
It returns an object of class
"covadapsim"
, which is a list containing the following elements:
summary.info |
|
Imbalances |
a list with the imbalance measures at the end of each simulated trial:
|
out |
For each replication returns a list of the data provided in input ( |
Pocock S J, Simon R. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. Biometrics, 1975, 31(1): 103-115.
See Also as PocSim
.
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res1 <- PocSim.sim(data = df1, covar = NULL, n = NULL, p = 0.85, nrep = 100) ### With covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- PocSim.sim(data = NULL, covar = c(2,2,3), n = 100, p = 0.85, nrep = 100)
require(covadap) # Here we set nrep = 100 for illustrative purposes, # Set it equal to at least 5000 for more reliable Monte Carlo estimates. ### With existing dataframe df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) # Simulate the design res1 <- PocSim.sim(data = df1, covar = NULL, n = NULL, p = 0.85, nrep = 100) ### With covariates # e.g. two binary covariates and one with three levels and 100 patients res2 <- PocSim.sim(data = NULL, covar = c(2,2,3), n = 100, p = 0.85, nrep = 100)
This function automatically recognizes the design implemented and provides a summary of the results.
summary_covadap(res)
summary_covadap(res)
res |
An object of class |
When applied to an object of class
"covadap"
:
if at least one qualitative covariate is present, the function returns the within-covariate imbalances reporting, for each level of each qualitative covariate, the difference in the number of patients assigned to A and B.
If instead at least one quantitative covariate is present, the function returns the difference in means. For each quantitative covariate, the difference in the mean in group A and B is reported.
When applied to an object of class
"covadapsim"
, it reports the averages, in absolute value, of the imbalance measures, strata imbalances and within-covariate imbalances of the nrep
trial replications according to the nature of the covariates.
The form of the value returned by summary_covadap
depends on the class of the argument provided (see Details).
#Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) res1 <- ECADE(data = df1, all.cat = TRUE, alloc.function = "Efron", rho = 0.85) summary_covadap(res1) res2 <- ECADE.sim(data = df1, cov = NULL, n = NULL, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 100) summary_covadap(res2)
#Create a sample dataset df1 <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), "age" = sample(c("18-35", "36-50", ">50"), 100, TRUE), "bloodpressure" = sample(c("normal", "high", "hyper"), 100, TRUE), stringsAsFactors = TRUE) res1 <- ECADE(data = df1, all.cat = TRUE, alloc.function = "Efron", rho = 0.85) summary_covadap(res1) res2 <- ECADE.sim(data = df1, cov = NULL, n = NULL, all.cat = TRUE, alloc.function = "Efron", rho = 0.85, nrep = 100) summary_covadap(res2)