Create a class of endpoint to specify its name, type and assign a random number generator.
Methods
Method new()
initialize an endpoint
Arguments
name
character vector. Name(s) of endpoint(s)
type
character vector. Type(s) of endpoint(s). It supports
"tte"
for time-to-event endpoints, and"non-tte"
for all other types of endpoints (e.g., continous, binary, categorical, or repeated measurement.TrialSimulator
will do some verification if an endpoint is of type"tte"
. However, no special manipulation is done for non-tte endpoints.readout
numeric vector with name to be the non-tte endpoint(s).
readout
should be specified for every non-tte endpoint. For example,c(endpoint1 = 6, endpoint2 = 3)
. If all endpoints are tte,readout
can beNULL
.generator
a RNG function. Its first argument must be `n`, number of patients. It must return a data frame of `n` rows. It support all built-in random number generators in
stats
, e.g.,stats::rnorm
,stats::rexp
, etc. that withn
as the argument for number of observations.generator
could be any custom functions as long as (1) its first argument isn
; and (2) it returns a vector of lengthn
or a data frame ofn
rows. Custom random number generator can return data of more than one endpoint. This is useful when users need to simulate correlated endpoints. The column names of returned data frame should match toname
exactly. If an endpoint is of type"tte"
, the customgenerator
should also return a column as event indicator. For example, if"pfs"
is"tte"
, then customgenerator
should return at least two columns"pfs"
and"pfs_event"
. Usuallypfs_event
can be all 1s if no censoring. Censoring can be specified later when defining theTrial
through argumentdropout
. See?Trial
. Note that if covariates, e.g., biomarker, subgroup, are needed in generating and analyzing trial data, they can be defined asEndpoint
as well....
optional arguments for
generator
.
Method test_generator()
test random number generator of the endpoints. It returns an example dataset.
Method print()
print an endpoint object