MortData ‐ SOA Database - hnlearndev/rslife GitHub Wiki
The RSLife package has a seperate module to parse XTbML which is XML schema used for this database table.
More information on XTbML can be found on the official website
Despite a common XML schema, the data itself does vary greatly in structure and thus, one common method to parse them all is not possible.
There are certain set rules to filtered which tables under which categories and under which usage can be loaded by RSLife package. However, there is no guarantee that it will work all the time. If you find yourself in situation that a certain data table cannot be loaded using the package, either:
- Email the author and request an individual case-by-case review
- Create a pull request if you can make modification
- Refine the data by yourself and use the custom data method to load your own data. Flexibility is at your own hand. More instruction can be found here.
More information can be found on the official website
A direct XML string follows format of XTbML can be used.
This is possible but not recommended. The method is still available for certain use case.
let xml_string = "<XTbML>
<ContentClassification>
<TableIdentity>1704</TableIdentity>
<ProviderDomain>soa.org</ProviderDomain>
<ProviderName>Susie Lee</ProviderName>
<TableReference>
Office for National Statistics, “English Life Table No. 15, 1990-92”, United Kingdom Statistics Authority, (England, 1997). Accessed: May, 2013 from http://www.ons.gov.uk/ons/rel/lifetables/decennial-life-tables/english-life-tables-no--15/english-life-tables--no--15.pdf
</TableReference>
<ContentType tc="84">Population Mortality</ContentType>
<TableName>ELT No. 15 (1990-92) – Female, ANB</TableName>
<TableDescription>
English Life Tables (ELT) Number 15 (1990-92) – Female. Basis: Age Nearest Birthday. Minimum Age: 0. Maximum Age: 112
</TableDescription>
<Comments>
Study Data: Estimates of the ‘central exposed to risk of death’ have been derived from the Office of National Statistics (ONS) estimates of the home population (that is, the persons usually resident in England and Wales, excluding foreign visitors and UK Armed Forces stationed elsewhere, but including civilian residents temporarily elsewhere, and all Armed Forces stationed in England and Wales) in mid-1990, mid-1991 and mid-1992. The reason for treating ages 90 and over differently is the problem of mis-statement of age of elderly people in censuses. Methodology: Crude central rates of mortality (mx) were constructed. In graduating the ELT 15, a variable-knot spline regression approach, as was used for ELT 14 (See SOA Table Identities 520 and 521) was adopted. The values for tqx at age 0 were obtained directly from the records of births and deaths in the years 1990-92. For the oldest ages, rates were found by extrapolation from the values of tqx obtained for age 85 to 103 for males and from 85 to 104 for females. Graduated central rates of mortality along with the extrapolated rates were converted to initial mortality rates (tqx). Data Transcription Errors: None. Data Certified: 05/2013.
</Comments>
<KeyWord>Aggregate</KeyWord>
<KeyWord>Population Mortality</KeyWord>
<KeyWord>United Kingdom</KeyWord>
</ContentClassification>
<Table>
<MetaData>
<ScalingFactor>0</ScalingFactor>
<DataType tc="2">Floating Point</DataType>
<Nation tc="44">United Kingdom</Nation>
<TableDescription>
English Life Tables (ELT) Number 15 (1990-92) – Female. Basis: Age Nearest Birthday. Minimum Age: 0. Maximum Age: 112
</TableDescription>
<AxisDef id="Age">
<ScaleType tc="3">Age</ScaleType>
<AxisName>Age</AxisName>
<MinScaleValue>0</MinScaleValue>
<MaxScaleValue>112</MaxScaleValue>
<Increment>1</Increment>
</AxisDef>
</MetaData>
<Values>
<Axis>
<Y t="0">0.00632</Y>
<Y t="1">0.00055</Y>
<Y t="2">0.00030</Y>
<Y t="3">0.00022</Y>
</Axis>
</Values>
</Table>
</XTbML>";
let el15_female = MortData::from_soa_xml_string(xml_string)?;
Instead of using a direct XML string, XML file of the same content can be use and loaded as data source.
let el15_female = MortData::from_soa_xml_file_path_str("data/t1704.xml")?;
Right click to obtain the XML url link which has a format of https://mort.soa.org/data/t{id}.xml
let el15_female = MortData::from_soa_url("https://mort.soa.org/data/t1704.xml")?;
Similar to pure url method but only ID is given as an input. More concise and recommended as a regular practise when using the package.
let el15_female = MortData::from_soa_url_id(1704)?;
Currently implement for Standard Ultimate Life Table that is regularly encounter in SOA examinations.
let su = MortData::from_soa_custom("SULT")?;