Learn R Programming

simcausal (version 0.5.7)

rdistr.template: Template for Writing Custom Distribution Functions

Description

Template function for writing SimCausal custom distribution wrappers.

Usage

rdistr.template(n, arg1, arg2, ...)

Value

A vector of length n

Arguments

n

Sample size that needs to be generated

arg1

Argument 2

arg2

Argument 1

...

Additional optional parameters

Details

One of the named arguments must be 'n', this argument is passed on to the function automatically by the package and is assigned to the number of samples that needs to be generated from this distribution. Other arguments (in this example arg1 and arg2) must be declared by the user as arguments inside the node() function that uses this distribution, e.g., node("Node1", distr="distr.template", arg1 = ..., arg2 = ...). Both, arg1 and arg2, can be either numeric constants or formulas involving past node names. The constants get passed on to the distribution function unchanged. The formulas are evaluated inside the environment of the simulated data and are passed on to the distribution functions as vectors. The output of the distribution function is expected to be a vector of length n of the sampled covariates.