Function Repository Resource:

MortalityConvert

Source Notebook

Convert vector descriptions of mortality into another representation

Contributed by: Seth J. Chandler

ResourceFunction["MortalityConvert"][vector,fromto]

takes a vector representing mortality using the form represented by from and converts it to the form represented by to.

Details and Options

from and to must be different strings taken from the set {"Hazard","Survival","Probability","CDF"}. Failure to do so generates an error message and returns $Failed.
The numeric values of a survival representation of mortality should be monotonically decreasing and the numeric values of a CDF representation should be monotonically increasing. Failure to satisfy these requirements generates an Undefined result.
Any numeric values for the hazard representation of mortality should be between 0 and 1 inclusive. Failure to satisfy this requirement generates an Undefined result.
Any numeric values for the probability representation of mortality should be between 0 and 1 and should sum to 1. Failure to satisfy either of these requirements generates an Undefined result.
ResourceFunction["MortalityConvert"] only works on discrete distributions and it assumes the time intervals between elements of the supplied vector are the same.

Examples

Basic Examples (4) 

Convert a description of mortality using "Hazard" into an equivalent description using "Survival":

In[1]:=
ResourceFunction["MortalityConvert"][{0.2, 0.4, 1}, "Hazard" -> "Survival"]
Out[1]=

Convert the previous description of mortality using "Survival" into an equivalent description using "Probability":

In[2]:=
ResourceFunction["MortalityConvert"][%, "Survival" -> "Probability"]
Out[2]=

Convert the previous description of mortality using "Probability" into an equivalent description using a cumulative distribution function (CDF):

In[3]:=
ResourceFunction["MortalityConvert"][%, "Probability" -> "CDF"]
Out[3]=

Convert the previous description of mortality using a cumulative distribution function into an equivalent description using "Hazard" (returning, thereby, to the original input):

In[4]:=
ResourceFunction["MortalityConvert"][%, "CDF" -> "Hazard"]
Out[4]=

Scope (5) 

If a symbolic vector is used as input, a conditional expression is generated:

In[5]:=
ResourceFunction["MortalityConvert"][{0.2, 0.3, 0.4, z}, "Probability" -> "CDF"]
Out[5]=

The vector may be purely symbolic:

In[6]:=
ResourceFunction["MortalityConvert"][Array[h, {5}], "Hazard" -> "Probability"]
Out[6]=

Conversions from one description to the same description return the original data:

In[7]:=
ResourceFunction["MortalityConvert"][{0.2, 0.3, 0.4}, "Hazard" -> "Hazard"]
Out[7]=

If an impossible vector is used as input, the result is Undefined:

In[8]:=
ResourceFunction["MortalityConvert"][{1, 0.7, -0.2, 0}, "Survival" -> "Hazard"]
Out[8]=

Unlisted representations (e.g. from spelling errors) generate a $Failed and an explanatory error message:

In[9]:=
ResourceFunction["MortalityConvert"][{1, 0.6, 0.2, 0}, "Survivial" -> "CDF"]
Out[9]=

Applications (2) 

Compute the expected value of death benefits with a mortality table given as a survival vector and a 100% interest rate, which is equivalent to a 50% discount rate:

In[10]:=
Expectation[0.5^t, t \[Distributed] EmpiricalDistribution[
   ResourceFunction["MortalityConvert"][{1, 0.8, 0.48, 0}, "Survival" -> "Probability"] -> {1, 2, 3}]
 ]
Out[10]=

Do the same computation using TimeValue and interest rates:

In[11]:=
Expectation[TimeValue[Cashflow[{{t, 1}}], 1, 0], t \[Distributed] EmpiricalDistribution[
   ResourceFunction["MortalityConvert"][{0.2, 0.4, 1}, "Hazard" -> "Probability"] -> {1, 2, 3}]
 ]
Out[11]=

Compute the expected value of a premium of $1 paid at the beginning of each year the person is alive with a mortality table given as a hazard vector and a 100% interest rate:

In[12]:=
Expectation[TimeValue[AnnuityDue[1, t], 1, 0], t \[Distributed] EmpiricalDistribution[
   ResourceFunction["MortalityConvert"][{0.2, 0.4, 1}, "Hazard" -> "Probability"] -> {1, 2, 3}]
 ]
Out[12]=

Compute the premium required to set the expected value of premiums equal to the expected value of death benefits given mortality stated in different ways:

In[13]:=
With[{dist = EmpiricalDistribution[
    ResourceFunction["MortalityConvert"][{1, 0.8, 0.48, 0}, "Survival" -> "Probability"] -> {1, 2, 3}]}, Solve[Expectation[0.5^t, t \[Distributed] dist] == Expectation[TimeValue[AnnuityDue[p, payments], 1, 0], payments \[Distributed] dist], p]
 ]
Out[13]=

Neat Examples (2) 

Compute the prospective reserve on an insurance policy at time z for which the insurer receives the same premium each year so long as the insured is alive, such that at the outset of the policy the expected time value of the premiums are equal to the expected time value of the death benefits:

In[14]:=
timeShiftedDistribution[z_, dist_] := TransformedDistribution[t - z, t \[Distributed] TruncatedDistribution[{z, \[Infinity]}, dist]]
In[15]:=
prospectiveReserve[dist_, z_] := Module[{timeShiftedDist, premium},
  timeShiftedDist = timeShiftedDistribution[z, dist];
  premium = p /. First@
     Solve[Expectation[TimeValue[Cashflow[{{t, 1}}], 1, 0], t \[Distributed] dist] == Expectation[TimeValue[AnnuityDue[p, payments], 1, 0], payments \[Distributed] dist], p];
  Expectation[TimeValue[Cashflow[{{t, 1}}], 1, 0], t \[Distributed] timeShiftedDist] - Expectation[TimeValue[AnnuityDue[premium, payments], 1, 0], payments \[Distributed] timeShiftedDist]
  ]
In[16]:=
Table[{z, prospectiveReserve[
   EmpiricalDistribution[
    ResourceFunction["MortalityConvert"][{1, 0.8, 0.48, 0}, "Survival" -> "Probability"] -> {1, 2, 3}], z]}, {z, 0, 2}]
Out[16]=

An insurer pays if risk 1 first materializes at time x and pays if risk 2 first materializes at time y, where the materialization of the risks are independent and the distribution of time at which either materializes is given as a list of hazard probabilities. Compute the expected present value of the insurer’s payout, assuming a 5% interest rate:

In[17]:=
probability1 = EmpiricalDistribution[
  ResourceFunction["MortalityConvert"][(90^6 - Range[0, 90]^6)/90^6, "Survival" -> "Probability"] -> Range[0, 89]]
Out[17]=
In[18]:=
probability2 = EmpiricalDistribution[
  ResourceFunction["MortalityConvert"][CompressedData["
1:eJwd0o8v1HEcx/HLqMgao62lK/2aIZz1g5Jei3SURn7k4io1bv06mRS7UCql
Swnv77mj7M6P1Bjy8yhNVlnYheVHuxSTH+sHo2WY0qde23OPf+C17uT5gMhF
PB4vlJWj+rd6tIXbeX+dqkUQDjeuKKxGp0BDzzWV2B2e7DMzWAFf1zMfg7Rl
aEpQSgrNS/GZ79ava36CrvcTPbFNxXgxMtZaznsEmWWZcFBWCHFtlizVpgAn
nNXb+bx8fED5q4k/aiSbuX4yXauGe/y+jP3aPLSGzjlPRjxEzNuXUSnuD+AY
ZnQvZFcu5nxWCWPFObAduXs0TaWCsE8X8XlCCYPxdE9bsRJFA21WmfpsBAes
9lafzYZ6X6jtZpNsiAVRqcE1CmjFv0NkZxX4fezUY0d7BZTyC4+2/eTQds/y
2uVmDtZbRWvNlBy2WLrErb/Aoc8iK2M+gEM3X27Ic+EQrdaP5q/hIBGGOkiN
OfwSBR+aniaYcoqQoRGCvNNk2XAfodssNq62nZDUruGsmgkBG4s2DGgJBsf9
CnoqCNW9RrLeJwSXmhyHpgKCzZtTDTF5hGci6cJ7FaHY85Z7B0fIKg0v9s8k
VO3QL+xNJ+zU873y0gjnsjUSPznB92eH4cFUQn3jvOvdmwQni8yIJSmEXQLN
4urrhMyWIUXaNcKtx2mRd5IJ6Ss9rpRcJeS0amnsCmET4oZ3MwNHRQ4lSQTX
yYtkx7wfZa1pSCTYtz21P8KMiP8eaMgskzXGNSQQDvgK7GVMhVTq7MEs4msu
mTOrHEpNRi8Tvr2+sbqZuTRYMK1hzvZ4zKYw+526cqVMJekiRUy375XjXszx
N8n6bczbPKN+G6ZEKiyzYvKX77EwZ5ajvHcJU7XdQrcgI9S969TNMMMk0XVT
zMEfX0//YMqNrdvHmC0+/i1fmIn/f0f4C5vaW/I=
"], "Hazard" -> "Probability"] -> Range[0, 89]]
Out[18]=
In[19]:=
NExpectation[
 If[x < y, TimeValue[Cashflow[{{x, 1/1.04^x}}], 0.05, 0], TimeValue[Cashflow[{{y, y/(90 (1.04)^y)}}], 0.05, 0]], {x, y} \[Distributed] ProductDistribution[probability1, probability2]]
Out[19]=

Publisher

Seth J. Chandler

Version History

  • 1.0.0 – 08 August 2019

Source Metadata

Related Resources

License Information