Saturday, May 28, 2022

Some Thoughts on Prophet (Part 2)

One of my favorite functionalities in Prophet is "parameterized extended formula". Although this technical term sounds a bit complex, the concept is in fact pretty straight forward - we can just relate to something we learned in the secondary school, i.e. "f(x)" (functions).

How parameterized extended formulas work is similar to self-defined function in Excel VBA. Say we have a function with multiple elements, e.g. f(x, y, z). When we input x = 2, y = 3 and z = 4 to this function, we may get a value of 10 directly. The same function can be used for different combinations of x, y and z - i.e. we can REUSE the function and make our calculation models more efficient.

We can use parameterized extended formulas for various areas, such as converting annual decrement rates to monthly rates. Instead of replicating similar formulas for death, TPD and CI separately, we can create a parameterized extended formula that can be used for death, TPD and CI at the same time:

  1. Create an extended formula that contain (say) 3 elements, say I call it as EXT_FORMULA.
  2. Create different extended formula for death, TPD and CI. Just one line code, #EXT_FORMULA(x, y, z) (it's hash-E-X-T-underscore-F-O-R-M-U-L-A). Say the extended formula for death is DTH_INPUT.
  3. To get the value from EXT_FORMULA, we need to specify the variable that carries values of elements, such as DTH_INPUT.QX (QX is a public variable under EXT_FORMULA).

Another reason I love using parameterized extended formula is it allows multiple outputs from the same extended formulas. For example, in case we have two separate public variables for male and female, we can define two public variables within the same parameterized extended formula, i.e. we can directly get the values from the variable by specifying (say) DTH_INPUT.QX_M and DTH_INPUT.QX_F.

You can also have numeric and text public variables at the same time. Both numeric and text public variables may appear as array variables if needed.


Further reading:

Some Thoughts on Prophet (Part 1)

Sharing is always a good thing. By sharing the knowledge I have, apart from providing others some ideas on how to improve their daily work or resolve the problems they encounter, I can still benefit from the sharing. Through writing posts in LinkedIn, I strengthen my knowledge and concepts, as well as gaining some inputs and view from other connections in my network.

For better records, I also put down my sharing under this blog, so that it is easier to be referred if needed.  

Thought (1): Debugger License - Get it if you have the budget

If you have additional budgets on Prophet licensing, I would suggest to get the Debugger license (yes, it needs a separate licensing). When you encounter errors in your Prophet runs, AND Prophet cannot display its run log (i.e. errors in both doing runs and displaying run logs at the same time) , Debugger will save your life (otherwise it may very tough to find out what the issue is).

If I can suggest enhancements on Prophet, I think it will be great if we can allow t-dependent calculation for TEXT variable as well. At the moment, Prophet doesn't allow t-dependent text variables - which create some hassles especially when we want to change the text values for different calculation loopings (CALC_LOOP).

P/S: We can also use PRINT_TO_FILE to output variables that we want to check into run logs.


Thought (2): No t dependent for text value?

To overcome this limitation, of course there is more than one way to handle it. For example, if the text value is a table name, we can vary the table names within READ_GENERIC_TABLE, under the numeric variable that we want to store the value read from the table.

Another approach I use quite a lot is using an extended formula to read the text value (it's OK to make the public variable within the extended formula to vary by calculation looping). Usually I will use ONE extended formula to read many text variables at the same time (so that can reduce no. of variables).

Of course, if you don't have debugger license, it is not easy to check text the value as it cannot be exported to normal text variable.


Further reading:

Get Inspiration for New Problems

In my last post and debut podcast, I talked about why strong foundations matter for coming up with smart, workable solutions in business. Bu...