Description Usage Arguments Format Construction Active field Public fields Public Methods Examples
A container for the supported model objects (see SupportedTransitionModels). When a model object is stored inside Model it can be assess using reference semantics. This is particularly useful when you want to store model objects inside World. By doing so, you can assess those models from World as it is flowing down a microsimulation pipeline just like Entities.
1 2 |
object |
a Model object |
... |
dots |
R6::R6Class object inheriting Generic.
1 |
x
:: (caret::train | data.table::data.table | named list
)
A model object that compatible.
name
:: character(1)
Name/Alias of the model.
preprocessing_fn
:: function()
A function that will be used to preprocess simulation data. E.g., this can
be used to filter which agents the model is applicable for.
model
(read-only) The stored model object in its original form.
name
:: character(1)
Name/Alias of the model.
preprocessing_fn
Default as NULL, this is to store a preprocessing function which will be
used to evaluate the entity data in Trans prior to simulating the
transition. A situation where this is useful could be when you want to limit
the use of a Model object to the specific group of agents (e.g: age between
x
and y
) that was used to estimate the model.
get()
() -> (caret::train | data.table::data.table | named list
)
Get a model object.
set(x)
(caret::train | data.table::data.table | named list
)
Get a model object.
modify()
An abstract method.
simulate()
An abstract method.
print()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | simple_prob_model <- Model$new(x = list(yes = 0.95, no = 0.05))
simple_glm_model <- Model$new(x = stats::glm(factor(sex) ~ age,
data = toy_individuals, family = "binomial"
))
# return the original model object
simple_prob_model$model
# add to world
world <- World$new()
world$add(simple_prob_model, name = "simple_prob_model")
world$add(simple_glm_model, name = "simple_glm_model")
# to access
world$get("simple_prob_model")
world$get("simple_glm_model")
# or alternatively you can use `get_model` which makes sure that it only looks
# through the named list of stored Model objects inside [World].
world$get_model("simple_prob_model")
world$get_model("simple_glm_model")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.