Assign treatment for stepped-wedge design

trtStepWedge(
  dtName,
  clustID,
  nWaves,
  lenWaves,
  startPer,
  perName = "period",
  grpName = "rx",
  lag = 0,
  xrName = "xr"
)

Arguments

dtName

data table

clustID

string representing name of column of cluster level ids

nWaves

number of treatment waves

lenWaves

the number of periods between waves

startPer

the starting period of the first wave

perName

string representing name of column of time periods

grpName

string representing variable name for treatment or exposure group

lag

integer representing length of transition period

xrName

string representing name of the field that indicates whether the cluster status is in transition status

Value

A data.table with the added treatment assignment

Examples

defc <- defData(
  varname = "ceffect", formula = 0, variance = 0.10,
  dist = "normal", id = "cluster"
)
defc <- defData(defc, "m", formula = 10, dist = "nonrandom")

# Will generate 3 waves of 4 clusters each - starting 2, 5, and 8

dc <- genData(12, defc)
dp <- addPeriods(dc, 12, "cluster")
dp <- trtStepWedge(dp, "cluster",
  nWaves = 3,
  lenWaves = 3, startPer = 2
)
dp
#> Key: <cluster>
#>      cluster period    ceffect     m timeID startTrt    rx
#>        <int>  <int>      <num> <num>  <int>    <num> <num>
#>   1:       1      0 -0.2031940    10      1        2     0
#>   2:       1      1 -0.2031940    10      2        2     0
#>   3:       1      2 -0.2031940    10      3        2     1
#>   4:       1      3 -0.2031940    10      4        2     1
#>   5:       1      4 -0.2031940    10      5        2     1
#>  ---                                                      
#> 140:      12      7 -0.1157863    10    140        8     0
#> 141:      12      8 -0.1157863    10    141        8     1
#> 142:      12      9 -0.1157863    10    142        8     1
#> 143:      12     10 -0.1157863    10    143        8     1
#> 144:      12     11 -0.1157863    10    144        8     1

dp <- addPeriods(dc, 12, "cluster")
dp <- trtStepWedge(dp, "cluster",
  nWaves = 2,
  lenWaves = 1, startPer = 4, lag = 3
)
dp
#> Key: <cluster>
#>      cluster period    ceffect     m timeID startTrt    xr    rx
#>        <int>  <int>      <num> <num>  <int>    <num> <num> <num>
#>   1:       1      0 -0.2031940    10      1        4     0     0
#>   2:       1      1 -0.2031940    10      2        4     0     0
#>   3:       1      2 -0.2031940    10      3        4     0     0
#>   4:       1      3 -0.2031940    10      4        4     0     0
#>   5:       1      4 -0.2031940    10      5        4     1     0
#>  ---                                                            
#> 140:      12      7 -0.1157863    10    140        5     1     0
#> 141:      12      8 -0.1157863    10    141        5     0     1
#> 142:      12      9 -0.1157863    10    142        5     0     1
#> 143:      12     10 -0.1157863    10    143        5     0     1
#> 144:      12     11 -0.1157863    10    144        5     0     1