Purpose
Extended formulas enhance and extend the capabilities of the Prophet programming language. They enable more complex calculations to be carried out than standard Prophet formulas. They are also able to retain the values that they have calculated from one model point to the next and from one loop to the next in a dynamic or stochastic run.
Examples of situations where extended formulas can be useful include:
- The calculation of commutation factors at the start of each product. The values can then be used in each model point instead of the commutation factors being calculated from the underlying mortality rates each time. This also means that in a dynamic run it is often possible to calculate just the variables for the months in the dynamic loop rather than for the whole policy term.
- The processing of policies that have a number of increments or benefits. Calculations can be carried out at the increment or benefit level and then be accumulated within an extended formula so that further calculations can be carried out at the policy level. For example, for a unit linked policy the allocations to units and the commission could be carried out at the increment level and the unit fund and sterling reserve calculations at the policy level.
- Separate calculations for each tranche of new PUPs, rather than just carrying out the calculations on the aggregate average of all PUPs.
- Rebasing of sterling reserve calculations.
- Scheme level calculations for group pension schemes.
- Dynamic Financial Analysis (DFA) for general insurance companies.
- Any other complex calculations that require looping or vectors.
Issues
Although extended formulas represent a significant extension to the standard Prophet programming language there are a number of issues to be aware of:
-
- Diagram view does not display the dependencies between the variables used in an extended formula, although it does show the normal variables which an extended formula uses and the normal variables that depend on an extended formula.
- The values calculated by the variables in an extended formula cannot be viewed, only the values calculated in normal variables. It is, however, easy to set up normal variables to read and display the values calculated by variables in extended formulas.
- The order of the calculations within an extended formula is not determined by Prophet automatically. Instead the calculations are always carried out in the order specified within the extended formula.
- Extended formulas are generally more difficult to set up, use and debug than normal formulas.
Implementation
Extended formula features can be used directly in any Prophet library formula by setting up an extended formula definition. You do this by selecting the Extended Formula definition from the Definition Type dialog box when specifying a variable.
The structure of an extended formula can take one of two formats:
- Standard extended formula
- Parameterised extended formula
A parameterised extended formula allows you to create a general purpose formula that can be called by any other formula. The arguments passed to the general formula are declared in the parameterised extended formula as parameters.
Normal Extended Formula Format
The layout of a standard extended formula appears as follows:
Variable declarations
...
Statements
...
Where:
Variable declarations: Are public and private variable declarations
Statements: Standard and extended formulas statements
Examples are:
PUBLIC Q(0,0) AS NUMBER
PRIVATE AGE AS NUMBER
PRIVATE SELECT AS NUMBER
Where variable Q is defined as a PUBLIC array variable and variables AGE and SELECT are defined as PRIVATE variables.
Parameterised Extended Formula Format
The layout of a parameterised extended formula appears as follows:Where:
Parameter declarations
...
Variable declarations
...
Statements
...
Where:
Parameter declarations: Are the declarations for each of the parameters that are used as the arguments when called by another formula.
Variable declarations: Are the public and private variable declarations
Statements: Standard and extended formulas statements
Note that a parameterised formula must have at least one parameter.
For example,
PARAMETER MORT_TABLE AS TEXT
PUBLIC Q(0,0) AS NUMBER
PRIVATE AGE AS NUMBER
PRIVATE SELECT AS NUMBER
Where MORT_TABLE
is a parameter, Q(0, 0)
is a two dimensional public array variable and AGE and SELECT are defined as private variables.
Conditional statements
If/Then/Else/EndIf statement, Switch / Case / Case Else / Endswitch
Looping statements
For/To/Step/Next, Do While/Loop, Do Loop/While, For Each / Next
Support for vector and array variables having up to 4 dimensions.
Declaration of local and global variables
This is achieved using the Private and Public variable declarations.
Instantiation of extended formulas with user defined parameters
Both number and text parameters are supported. This allows, for example, a single extended formula that calculates commutation factors to be called several times with different mortality tables and interest rates.
The retention of values
These are values calculated between different model points and between runs of the same product within a dynamic or stochastic run.