10.1 Creating Variables

There are three basic steps to remember when using a variable as a parameter in a decision tree:

  • Declare the variable name: Declare a clear name based on the variable's intended function in your model (following the naming guidelines outlined below).

  • Define the variable value: Define the variable value by assigning it a value (or a formula).

  • Reference the variable: Refer to the variable name anywhere the corresponding value is used in the tree (e.g., payoffs or probabilities).

TreeAge Pro offers multiple methods for each step; this chapter illustrates a few possible methods for creating and defining variables.

Guidelines for naming variables

Variable names must conform to certain rules (similar to Microsoft® Excel’s rules for cell names). Each variable name must:

  • contain only letters, numbers, and underscore characters

  • be no longer than 32 characters

TreeAge Pro will alert you if you try to use an invalid or duplicate variable name.

It is recommended that you follow a naming convention when creating variables in a particular model. For example, you could use the prefix “p” for probability variables, “c” for cost variables, and so on.

Variable names are not case-sensitive. For example, the names pUp, PUP and pup are equivalent; however, using case can be helpful in understanding variable names. Note that p_up would be a different variable since it includes an extra character.

Creating and defining variables

The simplest variable is one that represents a numeric input value. We will create an input variable now.

To create and define a new variable:

  • Open the Variables View.

  • Click the green "+" icon in the view toolbar. The Add/Change Variable or Function dialog will open.

  • Enter the variable name in the name field (Variable_Name_Here below).

  • Enter description and comment information for the variable (optional).

  • Enter the numeric value into the Root Definition - Build Expression field (12345 below)

  • Click OK.

The name Variable_Name_Here has been added to the list of recognized variable names in the tree in the Variable View, and it has been assigned a default numeric value of 12345 at the root node. You will see the definition beneath the root node in the Tree Diagram Editor.

A variable definition assigns a value (or formula) to a variable at a specific node. Most variables will be defined once at the root node, which will apply that definition to the whole model. However, variables can be defined at downstream nodes to use different definitions for different portions of the model.

In the Tree Editor window, if the name of your variable "wraps" then you can use the marks on the ruler to stretch a node length to better view variable definitions.

By default, variable definitions are displayed under the node where the variable is defined.

To hide/show all variable definitions in the tree:

  • Choose Tree > Tree Preferences from the menu or press the F11 key to open the Tree Preferences dialog.

  • Select the category Display > Variables/Markov Info.

  • Select "Show definitions" from the "Display definitions at node" options.

To hide/show a specific variable's definitions in the tree:

  • Open the Variables View.

    Uncheck or check the variable's property "Show in tree".