Skip to contents

Create a class of endpoint to specify its name, type and assign a random number generator.

Methods


Method new()

initialize an endpoint

Usage

Endpoints$new(name, type = c("tte", "non-tte"), readout = NULL, generator, ...)

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 be NULL.

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 with n as the argument for number of observations. generator could be any custom functions as long as (1) its first argument is n; and (2) it returns a vector of length n or a data frame of n 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 to name exactly. If an endpoint is of type "tte", the custom generator should also return a column as event indicator. For example, if "pfs" is "tte", then custom generator should return at least two columns "pfs" and "pfs_event". Usually pfs_event can be all 1s if no censoring. Censoring can be specified later when defining the Trial through argument dropout. See ?Trial. Note that if covariates, e.g., biomarker, subgroup, are needed in generating and analyzing trial data, they can be defined as Endpoint as well.

...

optional arguments for generator.


Method test_generator()

test random number generator of the endpoints. It returns an example dataset.

Usage

Endpoints$test_generator(n = 1000)

Arguments

n

integer. Number of random numbers generated from the generator.


Method get_generator()

return random number generator of an endpoint

Usage

Endpoints$get_generator()


Method get_readout()

return readout function

Usage

Endpoints$get_readout()


Method get_uid()

return uid

Usage

Endpoints$get_uid()


Method get_name()

return endpoints' name

Usage

Endpoints$get_name()


Method get_type()

return endpoints' type

Usage

Endpoints$get_type()


Method print()

print an endpoint object

Usage

Endpoints$print(categorical_vars = NULL)

Arguments

categorical_vars

categorical_vars character. Vector of categorical variables. This can be used to specify variables with limited distinct values as categorical variables in summary.


Method clone()

The objects of this class are cloneable with this method.

Usage

Endpoints$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Instead of using Endpoint$new, please use endpoint(), a user-friendly
# wrapper. See examples in ?endpoint.