qxtools.ijs

Script: ~addons/finance/finexec/qxtables/qxtools.ijs
Contributor: William Szuch
Updated: 2022-05-30
Depend: ~addons/finance/finexec/qxtables/al.ijs
        ~addons/finance/finexec/qxtables/alt.ijs
        ~addons/finance/finexec/qxtables/ann.ijs
        ~addons/finance/finexec/qxtables/elt.ijs
Definitions: loaded to locale base
Status: update
Script source: qxtools.ijs

Tools for for adjusting and modifying Qx tables.
Plot Qx tables.
This script loads all the Qx mortality tables.

Boxed Qx tables
‘0.5’ 8!:0 Qx_Data

Definitions

D descQx
P plotQx, plotz, plotzQx
Q quadfit, Qx_ALL, Qx_ALL_Boxed, Qx_ALT_Boxed, Qx_Data, Qx_Desc, Qx_DF, Qx_Names, Qx_Names_Desc, qxextend, QxF, QxM

Qx_ALL n list of all Qx tables
Qx_ALL_Boxed n boxed list of all Qx tables
Qx_ALT_Boxed n boxed list of Australian Life Tables
Qx_Data n qx values same order as Qx_Names
Qx_Desc n description of Qx Tables
Qx_DF n list of default tables
Qx_Names n names of Qx Tables
Qx_Names_Desc n names and description of Qx tables
QxF n default female Qx table : ALT_2010_12_F
QxM n default male Qx table : ALT_2010_12_M

descQx (monad)

Get description of the Qx table from name.
  descQx 'QxF'
  descQx 'ALT_2010_12_M'

plotQx (dyad)

Type: explicit
Depend: plot
Plot Qx tables (Jqt and JHS)

Syntax

(Qx)plotQx(A0 A1)
Qx = boxed list of Qx table names
A0,A1 = age range (integers)

Example

  ('QxF')plotQx(10 20)
  ('QxF';'QxM')plotQx(10 20)
  ('ALT_2013_15_M';'ALT_2010_12_M';'ALT_1960_62_M')plotQx(30 50)

Note

Use: Qx_ALL to show the available tables
     Qx_Names_Desc to a show boxed list of available tables

plotz (verb)

Form explicit
Copied from plotm in ~addons/finance/finexec/toolbox/plots.ijs
Allow for multiple plots in Qt.
Move plot window as required to show multiple plots.

Syntax

 plotz - as for plot

Example

  plotz i. 123
  plotz *: i. 123
  'title ASD' plotz *: i. 123
  plotz each (i.10);(i.100);(%: i. 100)
  ('title P1'plotz i. 10); ('title P2'plotz %: i. 100)

plotzQx (dyad)

Type: explicit
Depend: plot
Plot multiple tables (Jqt and JHS)

Syntax

(Qx)plotzQx(A0 A1)
Qx = boxed list of Qx table names
A0,A1 = age range (integers)
 For multiple plots ploltzQx [ plotzQx[plotzQx
 or on separate lines.

Example

  ('QxF')plotzQx(10 20)
  ('QxF';'QxM')plotzQx(10 20)
  ('QxF')plotzQx(10 20)
  ('QxF';'QxM')plotzQx(10 20)
  ('QxF')plotzQx(10 20)[('QxF';'QxM')plotzQx(10 20)  NB. 2 plots
  ('QxF')plotzQx(0 30)[('QxF';'QxM')plotmQx(30  60)[('QxF';'QxM')plotmQx(60 90)  NB. 3 plots
  ('QxF')plotzQx(10 20)
  ('QxF';'QxM)plotmQx(10 20)
  ('ALT_2017_19_M')plotzQx(0 30)[('ALT_1960_62_M')plotmQx(0 30)[('ALT_2017_19_M';'ALT_1960_62_M')plotzQx(0 30)

Note

Use: Qx_ALL to show the available tables
     Qx_Names_Desc to a show boxed list of available tables

quadfit (dyad)

Form: explicit
Calculate a quadratic curve from 2 values to a final value of 1
over a number of steps.
Used to calculate an extended Qx table by fitting a quadratic
from the last to two values of the Qx table to 1.

Syntax

(Qx)quadfit(N)
Qx = Qx table to be extended
N = number of years the Qx table is to be extended
    from last value to a final value of 1

Example

   (0.6 0.7)quadfit(5)
0.786667 0.86 0.92 0.966667 1
   (2 3)quadfit(5)
3.53333 3.6 3.2 2.33333 1
   (1 1.2 2 3)quadfit(5)
3.53333 3.6 3.2 2.33333 1
   (ALT_2005_07_M)quadfit(5)
0.389359 0.478886 0.610502 0.784207 1
   (ALT_2005_07_M)quadfit(1)
1
   (ALT_2005_07_M)quadfit(10)
0.358262 0.385597 0.423924 0.473244 0.533555 0.60486 0.687156 0.780445 0.884726 1
   (ALT_2005_07_M)quadfit(0)

qxextend (dyad)

Form: explicit
Depend: quadfit
Extend the qx table from the last value to a final value
of 1 over a number of years to terminate all lives.
This is done by By fitting a quadratic from last 2 values of
the Qx table to 1 after a further N years.
form:tacit
depend: quadfit

Syntax

(Qx)qxextend(N)
Qx = qx table to be extended
N = number of years the qx values to be extended

Example

   _5{. (ALT_2005_07_M)qxextend(5)
0.389359 0.478886 0.610502 0.784207 1
   _5{. (ALT_2005_07_M) qxextend(0)
0.32069 0.3261 0.3311 0.33657 0.34192
   _5{. (ALT_2005_07_M)qxextend(1)
0.3261 0.3311 0.33657 0.34192 1
   _10{. (ALT_2005_07_M)qxextend(10)
0.358262 0.385597 0.423924 0.473244 0.533555 0.60486 0.687156 0.780445 0.884726 1
   _5{.(ALT_2005_07_M)qxextend(5)
0.389359 0.478886 0.610502 0.784207 1