Description Construction Fields Methods Note
A class that perform Monte Carlo simulation on agents using a probabilistic model.
Work flow: initialise()
-> filter()
-> mutate()
-> simulate()
-> postprocess()
.
Note that, to swap the run order of filter()
and mutate()
you need to change the
mutate_first
public field to TRUE
.
1 |
x
:: R6
A Agent class inheritance object.
model
:: object
A model
target
:: [integer()
|Target]
(Default as NULL). A number that forces the number of micro events to occur. For example, if
'10“ is speficied, there will be 10 agents that under go the event. However,
if a integer vector is given it must be the same length as the classes in the model.
This only works for classification models. If a Target object is given, the
target values will be scaled down by the scaling factor of that was set by
the World object in your currently active environment.
targeted_agent
:: integer()
(Default as NULL) A integer vectors that contains ids of agents in x
to undergo the event.
mutate_first
:: logical(1)
Default as FALSE, this flag is used to indicate whether the attribute data from
the Agent in x
should be mutated ($mutate(.data)
) before filtered ($filter(.data)
).
See the description section for more details about the processing steps of Trans.
filter(.data)
(data.table::data.table()
) -> [data.table::data.table()]
(By default, first of the preprocessing steps)
By default this method returns the input .data
. This method can be overwrite
to give the user the flexibility to 'filter' the data prior to making prediction
by the given model. Filtering for eligible agents for this transition can be done in this step.
mutate(.data)
(data.table::data.table()
) -> [data.table::data.table()]
(By default, second of the preprocessing steps)
By default this method returns the input .data
. This method can be overwrite
to give the user the flexibility to 'mutate' the data prior to making prediction
by the given model. Adding derived variables and historical life course of the agents
can be done in this step.
update_agents(attr)
(character(1)
)
Update the attribute data of the agents that undergo the transition event.
get_result(ids)
(integer()
) -> data.table::data.table
Returns the simulation result in a data.table::data.table format with two
columns id
and response
.
get_nrow_result()
Returns the number of rows in the simulation result.
get_decision_maker_ids(response_filter = NULL)
(character()
) -> (integer()
)
Returns ids of the agents that have their response equal to response_filter
.
target
can be static or dynamic depending on the data structure of it. A static
target can be a named list or an integer value depending its usage in each
event function.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.