allocationTable {redcapAPI} | R Documentation |
Generate Allocation Tables for the Randomization Module
Description
These methods enable the user to generate allocation tables for the REDCap randomization module. Randomization may be stratified by other (categorical) variables in the data set as well as by Data Access Group. Additionally, randomization may be blocked to ensure balanced groups throughout the allocation
Usage
allocationTable(
rcon,
random,
strata = NULL,
group = NULL,
dag.id = NULL,
replicates,
block.size,
block.size.shift = 0,
seed.dev = NULL,
seed.prod = NULL,
weights = NULL,
...
)
## S3 method for class 'redcapApiConnection'
allocationTable(
rcon,
random,
strata = NULL,
group = NULL,
dag.id = NULL,
replicates,
block.size,
block.size.shift = 0,
seed.dev = NULL,
seed.prod = NULL,
weights = c(1, 1),
...
)
allocationTable_offline(
meta_data,
random,
strata = NULL,
group = NULL,
dag.id = NULL,
replicates,
block.size,
block.size.shift = 0,
seed.dev = NULL,
seed.prod = NULL,
weights = c(1, 1),
...
)
Arguments
rcon |
A |
random |
|
strata |
|
group |
|
dag.id |
|
replicates |
|
block.size |
|
block.size.shift |
|
seed.dev |
|
seed.prod |
|
weights |
An optional vector giving the sampling weights for each of the randomization
groups. There must be one number for each level of the randomization variable. If named,
the names must match the group labels. If unnamed, the group labels will be assigned in the
same order they appear in the data dictionary. The weights will be normalized, so they do
not need to sum to 1.0. In other words, |
... |
Arguments to pass to other methods |
meta_data |
|
Details
Each element in block.size
must be a multiple of the number of
groups in the randomized variable.
The 'offline' version of the function operates on the data dictionary file downloaded from REDCap. This is made available for instances where the API cannot be accessed for some reason (such as waiting for API approval from the REDCap administrator).
The value of replicates
controls how many allocations are generated. It
is possible to get slightly more replicates than requested if your blocking design
cannot exactly match replicates. For example, if the users asks for 30 replicates in
blocks of 8, a warning will be printed and 32 replicates will be returned in the
randomization table.
Value
Returns a list with the elements
dev_allocation | data.frame with the randomization allocations for the development environment. |
prod_allocation | data.frame with the randomization allocations for the production environment. |
dev_seed | The random seed values for the development environment. |
prod_seed | The random seed values for the production environment. |
blocks | Blocking scheme used to generate the randomization. |
weights | Weighting scheme for the randomization. |
Examples
## Not run:
unlockREDCap(connections = c(rcon = "project_alias"),
url = "your_redcap_url",
keyring = "API_KEYs",
envir = globalenv())
allocationTable(rcon,
random = "treatment_assignment",
strata = c("demographic_group", "hospital_group"),
replicates = 12,
block.size = 4,
seed.dev = 12345,
seed.prod = 54321)
## End(Not run)