14.3 Referencing Tables via Table Lookup

There are two basic ways to use tables:

  1. In order to look up a value in the table for a payoff, probability, or other calculation, you will need to use the proper lookup syntax (as described below).

  2. A table can be used as a sampling distribution, simply select its name from a list of tables when setting up the distribution. This is described in the section Sampling from tables.

The Special Features example model called Table Lookups.trex shown below includes examples of table lookups and reverse table lookups.

Table lookup syntax

In a table composed of index-value pairs (i.e., one column with an index and a value column), a value can be retrieved with the following syntax:

TableName[index]

The table’s name (TableName) is followed immediately by square brackets containing an index used to pick a table row. The index expression can be a number, a variable, or even another table reference.

If a table has more than one column of values, you will need to specify the number of the column you want to pick from. The syntax will now require row index argument first and then column number:

TableName[index; value_column]

The value_column expression can also be a number, variable, etc. However, this expression normally resolves to an integer value <= the number of columns in the table. Note that when looking at the table, the first value column is actually the second column in the table because the first column contains the index.

For tables with more than one value column, table lookups without a value_column provided will use the default value column defined in the table properties.

Table lookup methods

During tree calculations, if a formula references a table using an index value that matches a row index in the table exactly, TreeAge simply returns the value from the appropriate column in that row. However, when a reference is made to a non-existent row/index, the table’s missing row lookup method determines what is returned.

TreeAge Pro supports interpolation of both rows and columns. The table below is used to show how TreeAge Pro handles table lookups with interpolation. Consider the table below, TestTable.

First consider how the lookup works when an index is found:

TestTable[10;1] = 1,000

TestTable[20;2] = 20,000

Linear Interpolation when the index is not found. It starts with the value below the provided index value. Then it adds the difference between the next higher value and the lower value based on the proportion of the way from the lower index to the higher index.

TestTable[14;1] = TestTable[10;1] + ( (14-10)/(20-10) )*( TestTable[20;1]-TestTable[10;1 ])

TestTable[14;1] = 1,000 + (4/10)*(1000) = 1,400

TreeAge Pro supports simultaneous interpolation of both rows and columns. First interpolation is done on the row values and then those row interpolated values are used for the column interpolation.

TestTable[16;1] = 1,600

TestTable[16;2] = 16,000

TestTable[16;1.4] = 1,600 + ((1.4-1)/(2-1))*(16,000-1,600) = 1,600 + (.4/1)*14,400 = 7,360

Spline Interpolation works in a similar way, but the spline is non-linear, so interpolation will follow the spline trend among index and value pairs in the table.

Reverse table lookups

TreeAge Pro allows you to use tables in reverse - feed in a value and return an index. There are two forms of syntax for this. We recommend the first described immediately below.

Syntax: TableReverse("<tableName>"; <value>; <column>)

The TableReverse command requires three arguments - the table name in quotes, the value provided for the lookup, and the value column in which to look for a match.

Reverse table lookups do not support spline interpolation.

Old syntax for reverse table lookups is described below. However, we recommend using the newer syntax above.

Special syntax for the Command() function enables reverse table lookups. This is designed to facilitate, for example, using a uniform[0,1] random number to "sample" age-at-event table from an age-indexed table whose value columns describe one or more inverse "survival" functions, or "cdfs". The syntax is:

Command("TABLES";"t_events";"ReverseLookup"; prob; value_column)

Other methods are: "ReverseLookupInterpolate", "ReverseLookupTruncate", and "ReverseLookupCeiling". Refer to the Tools and Functions for Complex Trees Chapter for additional information.