| define_conditions | R Documentation |
Combine conditional data-generation rules into a specification
define_conditions(...)
... |
One of three forms. Rules. Specification columns given as named vectors ( Objects created by The forms cannot be mixed in one call. In the column form, |
A simulab_condition_spec base data.frame. Rules written with
when() give one row per parameter, with columns rule, variable,
condition, distribution, parameter and value; the other two forms
give one row per rule with the formula/variance columns.
# Rules. One line per rule; a repeated name gives a variable several rules.
define_conditions(
outcome = when(group == 1, normal(mean = 5, sd = 1)),
outcome = when(group == 0, poisson(lambda = 2)),
bonus = when(group == 1, gamma(shape = 2, rate = 0.5))
)
# One call, named arguments, one row per rule.
define_conditions(
variable = c("outcome", "outcome"),
condition = c("group == 1", "group == 0"),
formula = c("2", "0"),
variance = "1"
)
# Definitions built one at a time are still accepted.
define_conditions(
define_condition("outcome", condition = "group == 1",
formula = "2", variance = "1", distribution = "normal"),
define_condition("outcome", condition = "group == 0",
formula = "0", variance = "1", distribution = "normal")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.