design_sw: Build a stepped-wedge cluster randomised trial design binary...

View source: R/design_sw.R

design_swR Documentation

Build a stepped-wedge cluster randomised trial design binary treatment indicator matrix

Description

design_sw builds a binary treatment indicator matrix for a specified conventional (i.e., two treatment conditions, say control and experimental interventions) stepped-wedge cluster randomised trial (SW-CRT) design, for subsequent use with draw_sw.

Usage

design_sw(clusters_per_time_period = c(0, 1, 1, 1, 1),
          labels                   = c("0", "1"),
          row_names                =
            1:sum(clusters_per_time_period),
          col_names                 =
            1:length(clusters_per_time_period))

Arguments

clusters_per_time_period

A numeric vector; element clusters_per_time_period[i] indicates the number of clusters that switch to the experimental intervention in time period i. The length of clusters_per_time_period thus indicates the number of time periods. Defaults to c(0, 1, 1, 1, 1).

labels

A vector of length two, giving labels for the two intervention conditions. Defaults to c("0", "1").

row_names

A vector, giving rownames to add to the produced design. Must have length equal to sum(clusters_per_time_period).

col_names

A vector, giving colnames to add to the produced design. Must have length equal to length(clusters_per_time_period).

Value

Returns the binary treatment indicator matrix, in matrix form, for the implied SW-CRT design. This can be passed to draw_sw.

Author(s)

Michael J Grayling (michael.grayling@newcastle.ac.uk)

See Also

draw_sw

Examples

# The default is a 'standard' SW-CRT design, with four clusters and five time
# periods
default_design <- design_sw()
# Specify a more complex design, where all clusters begin in the intervention
# condition, there is an unequal number of clusters who switch per time
# period, and there are two trailing extra time periods with all clusters in
# the intervention condition. Also modify the row and column names
complex_design <- design_sw(clusters_per_time_period = c(1, 2, 3, 2, 0, 0),
                            row_names                = paste("Cluster", 1:8),
                            col_names                = paste("Time period",
                                                             1:6))

mjg211/swcrt documentation built on May 1, 2022, 4:26 a.m.