HuHu.sim {covadap}R Documentation

Simulations of the Covariate-Adaptive randomization by Hu and Hu

Description

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.

Usage

#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)

Arguments

data

a data frame or a matrix. Each row of data corresponds to the covariate profile of a patient. To be specified if covariate profiles should be sampled from an existing dataset provided in data.

covar

either a vector or a list to be specified only if data = NULL. It could be a vector with length equal to the number of covariates and elements equal to the number of levels for each covariate. Otherwise it is a list containing the covariates with their levels (e.g. one covariate with two levels and one with three covar = list(cov1 = c("lev1", "lev2"), cov2 = c("lev1", "lev2", "lev3")).

n

number of patients (to be specified only if data = NULL).

p

biased coin probability for the Efron's allocation function (1/2 \leq p \leq 1). The default is 0.85.

omega

vector of weights for the overall, within-stratum, and within-covariate-margin levels. If NULL (default) omega = rep(1/(n_cov + 2), n_cov + 2).

nrep

number of trial replications.

print.results

logical. If TRUE a summary of the results is printed.

Details

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.

Value

It returns an object of class "covadapsim", which is a list containing the following elements:

summary.info

Design name of the design,

Sample_size number of patients,

n_cov number of covariates,

n_levels number of levels of each qualitative covariate,

var_names name of the covariates,

n.rep number of replications,

Maximum_tolerated_imbalance for the BSD procedure.

Imbalances

a list with the imbalance measures at the end of each simulated trial:

Imb.measures summary of overall imbalances (Loss loss, Mahal Mahalanobis distance, overall.imb difference in the total number of patients assigned to A and B),

within.imb within-covariate imbalance: difference in the number of patients assigned to A and B for each level of each qualitative covariate,

strata.imb the within-stratum imbalance (i.e. difference in the total number of patients assigned to A and B within the stratum),

strata.A total number of patients assigned to A within the stratum,

strata.N total number of patients assigned to each stratum,

obs.strata matrix of the possible strata.

out

For each replication returns a list of the data provided in input (data) and the resulting assignments (Assignment).

References

Hu Y, Hu F. Asymptotic properties of covariate-adaptive randomization. The Annals of Statistics, 2012, 40(3): 1794-1815.

See Also

See Also HuHu.

Examples

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)


[Package covadap version 1.0.1 Index]