trtStepWedge {simstudy} | R Documentation |
Assign treatment for stepped-wedge design
Description
Assign treatment for stepped-wedge design
Usage
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
See Also
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
dp <- addPeriods(dc, 12, "cluster")
dp <- trtStepWedge(dp, "cluster",
nWaves = 2,
lenWaves = 1, startPer = 4, lag = 3
)
dp
[Package simstudy version 0.8.1 Index]