loadSimFrame: Creates a simulation frame. A simulation frame is the set of...

loadSimFrameR Documentation

Creates a simulation frame. A simulation frame is the set of all variables (input, intermediate, and outcome) used or produced by models during a simulation. During simulation the simulation frame will contain the current iteration's set of variables being used in the simulation. This function establishes the values of the simulation frame at the start prior to simulation by evaluating the initial value expression specified by the simframe definition.

Description

Creates a simulation frame. A simulation frame is the set of all variables (input, intermediate, and outcome) used or produced by models during a simulation. During simulation the simulation frame will contain the current iteration's set of variables being used in the simulation. This function establishes the values of the simulation frame at the start prior to simulation by evaluating the initial value expression specified by the simframe definition.

Usage

loadSimFrame(
  simframe_defn,
  envir = .GlobalEnv,
  enclos = parent.frame(),
  na_omit = FALSE
)

Arguments

simframe_defn

simframe definition. A dataframe of variables that define the simframe: $Varname - the name of a variable in the simframe $Previous_var - the name of a variable in which to store the current value in at the beginning of each iteration (i.e: before it's transformed). Optional - for models that require previous state. $Initial_value - an expression that generates the initial value of the variable. The expression is evaluated in the context of envir. If empty then an initial numeric value of NA is used. $Outcome_type - if specified, indicates this is an outcome variable and indicates its type which is one of "categorical" or "continuous" $Outcome_module - if specified, indicates the Simmmodule this outcome variable belongs to

envir

environment to evaluate initial_value in. Typically this will be a dataframe loaded from a base file. Initial_value can not only reference values in envir, but also values in enclos. Defaults to global environment.

enclos

Specifies the enclosure, i.e., where R looks for objects not found in envir. Defaults to the caller's environment (parent.frame())

na_omit

If TRUE and an observation is NA, then that case (ie: it's observations for all variables) is removed. This however does not apply to initial_value expressions that return a singular NA. These remain as a vector containing NA for as each observation.

Value

the simulation frame. The simulation frame contains the variables in simframe_defn with their inital_value evaluated. Each variable contains a set of observations. Each observation represents a case in the basefile.

The simulation frame object has the following attributes:

"previous" - variables that represent values in the previous iteration "outcome_vars" - a dataframe of Varname, Outcome_type, and Outcome_module "na.actions" - an omit variable that indicates the observations that were removed because their were NA. Initial_values that returned a singular NA remain.


kcha193/simarioV2 documentation built on April 8, 2024, 4:51 p.m.