Examples¶
This section contains practical examples demonstrating how to use the lost_years package to calculate expected years lost using different data sources.
Overview¶
The examples showcase the three main functions of the package:
lost_years_ssa: Calculate expected years lost using US Social Security Administration datalost_years_hld: Calculate expected years lost using international Human Life-Table Databaselost_years_who: Calculate expected years lost using WHO life expectancy data
Available Examples¶
- Using
lost_years - Average Number of Years Lost For People Who Died of Coronavirus in China
- Prepare example input in DataFrame
- Get Human Life Table data columns from HLD dataset
- Assuming all the people who died were at the bottom of the age ranges
- Assuming all the people who died were at the top of the age ranges
- Assuming all the people who died were at the middle of the age ranges
- Assume the Longevity is the Same as People in the US
- Assume Everyone Lives Till 90
- Average Number of Years Lost For People Who Died of Coronavirus in France
- Prepare example input in DataFrame
- Get Human Life Table data columns from HLD dataset
- Assuming all the people who died were at the bottom of the age ranges
- Assuming all the people who died were at the top of the age ranges
- Assuming all the people who died were at the middle of the age ranges
- Assume the Longevity is the Same as People in the US
- Assume Everyone Lives Till 90
- Get Human Life Table data columns from WHO dataset
- Assuming all the people who died were at the bottom of the age ranges
- Get Human Life Table data columns from WHO dataset
- Assuming all the people who died were at the top of the age ranges
- Get Human Life Table data columns from WHO dataset
- Assuming all the people who died were at the middle of the age ranges
- Average Number of Years Lost For People Who Died of Coronavirus in France
- Prepare example input in DataFrame
Basic Usage Example¶
The basic example demonstrates simple usage with sample data across different countries and demographics.
COVID-19 Analysis Examples¶
The coronavirus examples show real-world applications analyzing the impact of COVID-19 on life expectancy across different countries and time periods:
corona_virus.ipynb: General COVID-19 impact analysis
corona_virus_fr.ipynb: Focused analysis on France
corona_virus_fr_daily.ipynb: Daily analysis for France
These examples use real COVID-19 mortality data to demonstrate practical applications of the lost years calculations.
Warning
The three COVID-19 notebooks were written against an earlier lookup contract
and their committed outputs predate the correctness fixes described in the
data dictionary. Their lost_years_who cells pass an
age mapping, which now raises: the packaged WHO indicator is life expectancy
at birth and never had an age dimension, so those cells were reporting
at-birth figures as if they were remaining years at a given age. Their
lost_years_hld cells relied on the old, unflagged snap to the nearest
Year1, which for China reaches back to the 1981 life table. Re-running these
analyses means redoing them, not re-executing them; the numbers they report
should be treated as provisional until that happens. examples/example is
current.
Data Sources¶
The examples use data from:
CDC COVID-19 mortality data
WHO life expectancy statistics
SSA actuarial tables
HLD international life tables
All data files are included in the data/ subdirectory for reproducibility.