This notebooks explores the fastlife model, a parallel processing model, by taking a closer look at some of the Spaces unique to the fastlife model.
If you're viewing this page as a static HTML page on https://lifelib.io, the same contents are also available here on binder as Jupyter notebook executable online (it may take a while to load). To run this notebook and get all the outputs below, Go to the Cell menu above, and then click Run All.
The fastlife model is saved as a folder named model in the fastlife folder. To create a live model, import modelx and call read_model
function by passing the folder path.
import modelx as mx
model = mx.read_model("model")
The previously created model is renamed automatically to avoid name conflict. To get all existing models, get_models
modelx API function can be used. get_models
returns a dict of all the existing models associated with their names.
import modelx as mx
mx.get_models()
The present values of net cashflows are calculated in PV_NetCashsflow
Cells in the Projection
Space.
model.Projection.PV_NetCashflow(0)
Unlike the simplelife model, PV_NetCashflow
returns a pandas Seris object with Policy index. Each element of the returned Series is the present value of the net cashflow of each model point. Below is the formula of PV_NetCashflow
.
model.Projection.PV_NetCashflow.formula
As you see, PV_NetCashflow
at time 0 is the sum of PV_PremIncome
, PV_ExpsTotal
and PV_BenefitTotal
.
model.Projection.PV_PremIncome(0)
model.Projection.PV_PremIncome.formula
Most of the Cells in Projection
Space operate on Serieses indexed by Policy just like PV_NetCashflow
, because their precedent Cells operate on Serieses with the same index.
The Projection
Space have a child Space named Policy
. Policy
contains policy data and Cells to calculate policyholder values. The PolicyData
Reference holds a PandasData
object, which internaly stores policy data read from an input file as a pandas DataFrame.
model.Projection.Policy.PolicyData
To get the DataFrame stored in the PolicyData
object, call it:
model.Projection.Policy.PolicyData()
PolicyData
is a PandasData
object, and it was created by the new_pandas method of UserSpace
. The location of the input file can be acquired as its path
attribute.
model.Projection.Policy.PolicyData.path
There are many Cells in Policy
whose roles are for calculating policyholder values such as premiums and cash surrender values from commutation functions and actuarial notations.
For example, GrossPremRate
is for calculating gross premium rates:
model.Projection.Policy.GrossPremRate.formula
As we see in the Projection
Space, GrossPremRate
also retuns results for all model points in a Series with the Policy index.
model.Projection.Policy.GrossPremRate()
Projection
has another space named Assumptions
. Assumptions
associates projection assumptions to model points, by looking up paramters in a table stored as an ExcelRange
object associated to a Reference named Assumption
.
model.Projection.Assumptions.Assumption
Just like PandasData
objects, Assumption
has the path
attribute hoding a path to its input file.
model.Projection.Assumptions.Assumption.path
Assumption
is a dict-like object, whose keys are tuples of assumption type, product ID, policy type ID and genration ID. For example, For the assumption type 'Surrender' and product 'TERM'
model.Projection.Assumptions.Assumption["Surrender", "TERM", None, None]
Most of the Cells in the Assumption
Space are for lookup operations just like the above example. The lookup results are also in Series.
model.Projection.Assumptions.SurrRateID()