Randomize a two-armed cluster trial
randomizeCRT.Rd
randomizeCRT
carries out randomization of clusters and
augments the trial data frame with assignments to arms
Usage
randomizeCRT(
trial,
matchedPair = FALSE,
baselineNumerator = "base_num",
baselineDenominator = "base_denom"
)
Arguments
- trial
an object of class
"CRTsp"
or a data frame containing locations in (x,y) coordinates, cluster assignments (factorcluster
), and arm assignments (factorarm
). Optionally: specification of a buffer zone (logicalbuffer
); any other variables required for subsequent analysis.- matchedPair
logical: indicator of whether pair-matching on the baseline data should be used in randomization
- baselineNumerator
name of numerator variable for baseline data (required for matched-pair randomization)
- baselineDenominator
name of denominator variable for baseline data (required for matched-pair randomization)
Value
A list of class "CRTsp"
containing the following components:
design | list: | parameters required for power calculations |
geom_full | list: | summary statistics describing the site |
geom_core | list: | summary statistics describing the core area (when a buffer is specified) |
trial | data frame: | rows correspond to geolocated points, as follows: |
x | numeric vector: x-coordinates of locations | |
y | numeric vector: y-coordinates of locations | |
cluster | factor: assignments to cluster of each location | |
pair | factor: assigned matched pair of each location
(for matchedPair randomisations) | |
arm | factor: assignments to "control" or "intervention" for each location | |
... | other objects included in the input "CRTsp" object or data frame |
Examples
# Randomize the clusters in an example trial
exampleCRT <- randomizeCRT(trial = readdata('exampleCRT.txt'), matchedPair = TRUE)
#> *** No baseline data for matching. Unmatched randomisation ***
#> *** computed distance to nearest measurements in discordant arm ***