genNthEvent {simstudy} | R Documentation |
Generate event data using longitudinal data, and restrict output to time until the nth event.
Description
Generate event data using longitudinal data, and restrict output to time until the nth event.
Usage
genNthEvent(dtName, defEvent, nEvents = 1, perName = "period", id = "id")
Arguments
dtName |
name of existing data table |
defEvent |
data definition table (created with defDataAdd) that determines the event generating process. |
nEvents |
maximum number of events that will be generated (the nth event). |
perName |
variable name for period field. Defaults to "period" |
id |
string representing name of the id field in table specified by dtName |
Value
data.table that stops after "nEvents" are reached.
Examples
defD <- defData(
varname = "effect", formula = 0, variance = 1,
dist = "normal"
)
defE <- defDataAdd(
varname = "died", formula = "-2.5 + 0.3*period + effect",
dist = "binary", link = "logit"
)
d <- genData(1000, defD)
d <- addPeriods(d, 10)
dx <- genNthEvent(d, defEvent = defE, nEvents = 3)
[Package simstudy version 0.8.1 Index]