-
-
Notifications
You must be signed in to change notification settings - Fork 1
MortData ‐ Custom data
Willian Nguyen edited this page Aug 4, 2025
·
1 revision
If the custom mortality and morbidity data is used out of SOA XML and IFOA XLS format, the data schema must follow the below three options:
Single mortality rate per age - the most common format:
| age | qx |
|-----|---------|
| 25 | 0.00120 |
| 26 | 0.00135 |
| 27 | 0.00150 |
| ... | ... |
Survivor function format - same data expressed as remaining lives:
| age | lx |
|-----|----------|
| 25 | 100000.0 |
| 26 | 99880.0 |
| 27 | 99745.1 |
| ... | ... |
Mortality rate under selection effect (based on duration since issued)
| age | qx | duration |
|-----|---------|----------|
| 35 | 0.00080 | 1 |
| 35 | 0.00095 | 2 |
| 35 | 0.00110 | 3 |
| 36 | 0.00085 | 1 |
| 36 | 0.00102 | 2 |
| 36 | 0.00118 | 3 |
| ... | ... |... |
// DataFrames - qx
let df_qx = df! {
"age" => [25u32, 26, 27],
"qx" => [0.001f64, 0.0012, 0.0015],
}?;
// Custom data from dataframe
let data_from_df_with_qx = MortData::from_df(df_qx)?;
// DataFrames - lx
let df_lx = df! {
"age" => [25u32, 26.0, 27.0],
"lx" => [100000.0f64, 99900.0, 99780.0],
}?;
// Custom data from dataframe
let data_from_df_with_lx = MortData::from_df(df_lx)?;
- Backbone of cutom data import under struct MortData
- All others custom data import will use this method as medium.
- Underlied with rules and validation to support data integrity and related calculation.
- age data must be consecutive with no gap and u32 convertible
- qx and lx must be f64 convertible
- qx must be between 0 and 1.
// Custom data from spreadsheet XLSX
let data_from_xlsx = MortData::from_ods("data/mortality.xlsx", "select")?;
- Sheet name is required.
- Header is at the first row (row A).
- Data starts from second row (row B).
// Custom data from spreadsheet ODS
let data_from_ods = MortData::from_ods("data/mortality.ods", "select")?;
Similar to from_xlsx method but used for ods files.