Variables - zward/Amua GitHub Wiki

Variables can be defined to keep track of model events and dynamically update expressions as the model runs. Thus, unlike parameters which are fixed for a given run of the model, variables can change within a simulation. Variables may change across individuals, allowing heterogeneity to be modeled, or they may change over time.

Variable names can be referenced globally (like parameters), but variable values are local (i.e. tracked separately) within each strategy or Markov Chain . In cohort simulations, each variable has a single value per model cycle. In Monte Carlo simulations the variables for each individual are updated separately.

At the beginning of the model, all Variables are initialized to the values entered in their 'expression' textbox.

Variable Updates

Variables are updated via Variable Update expressions attached to nodes (see below). Any dependent variables will also be updated after all explicitly-defined variable updates are performed.

Variable update expressions can be added to nodes by clicking the Add/Remove Variable Update button on the toolbar or pop-up menu. Variable Updates are applied on entry to each node before any other node attributes are evaluated.

In Markov models, Variable Updates attached to a Markov Chain node provide two fields - you can enter variable updates for one or both:

  • V(t0): Updates are performed on entry to the Markov chain (i.e. only at the beginning of cycle 0). This can be used to set variables that vary by chain.
  • V(t+): Updates will be performed at the beginning of each cycle, starting at cycle 1. This can be used to update variables that change every cycle for all states (e.g. age).

Only one variable update field is provided per node, but multiple expressions can be entered by placing ; symbols between each update expression.

Variables are updated via assignment operators that change the value of the current variable. The following assignment operators are allowed.

For these examples the variable is initialized to var = 3.

Operator Description Example
= Equals var = 3 + 3 -> var=6
++ Increment by 1 var++ -> var=4
-- Decrement by 1 var-- -> var=2
+= Add to the current value var+=2 -> var=5
-= Subtract from the current value var-=2 -> var=1
*= Multiply the current value var*=2 -> var=6
/= Divide the current value var/=2 -> var=1.5