infer_natural_mortality
infer_natural_mortality(year_age_rate_data, interval_fit=None, predict_horizon=2100.0)
Convert the raw mortality data to what would have been the expected natural mortality had HIV not caused a spike in mortality. This algorithm assumes that during the 'interval_fit' mortality rates had a relatively steady decline (i.e. less people were dying each year), but shortly after the 'interval_fit' there was a spike in mortality. The algorithm uses the data in the 'interval_fit' and extrapolates it out over the time period.
It assumes that the input data is for only one node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year_age_rate_data
|
YearAgeRate
|
This is a YearAgeRate data object containing the raw mortality data, probably output from the extract_mortality() function |
required |
interval_fit
|
tuple[float, float]
|
This tuple contains the range of years that we want to determine the mortality trend before the HIV epidemic. These years will be extrapolated from the end of the fit forward. |
None
|
predict_horizon
|
float
|
This determines how far out the data will be extrapolated. |
2100.0
|
Returns:
| Type | Description |
|---|---|
YearAgeRate
|
A YearAgeRate object with the inferred mortality rates. |
Source code in emodpy_hiv/demographics/infer_natural_mortality.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
mortality_read_infer_plot(country, version, gender, interval_fit=None, save_data=False, other_csv_filename=None, img_dir=None, filename_to_save_to=None)
Extract the mortality data from the given file for the given country and plot both the raw data and the inferred data (without HIV deaths). The plot window will have a plot for each age where the data in the plot shows the rate per year for that age group. The label shows the minimum age of the band. This means that the age range being represented is from this value to the next largest age that is plotted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country
|
str
|
The name of the country to be extracted. It must match exactly to the country name used in the referenced spreadsheet. |
required |
version
|
str
|
The year/version of the indicated spreadsheet. Each year has a slightly different format. Supported versions are 2012, 2015, 2019, 2024 |
required |
gender
|
str
|
The gender of the data to be extracted. Possible values are 'male' and 'female'. |
required |
save_data
|
bool
|
If true (default is False), two YearAgeRate CSV formatted files are output into the current directory. The files are: 'raw_mortality_year_age_rate.csv' and 'mortality_minus_hiv_year_age_rate.csv'. |
False
|
other_csv_filename
|
str
|
If the filename is defined, it reads an expected YearAgeRate CSV file and plots it with the raw and inferred data from the spreadsheet. This allows the user to plot other mortality data (i.e. older versions) with the new data. |
None
|
img_dir
|
str
|
If this is defined, the images are saved to this directory. If not defined, the images are displayed in a window. |
None
|
filename_to_save_to
|
str
|
The name of the file to save the image to. This is only used if img_dir is defined. |
None
|
Return
No return
Source code in emodpy_hiv/demographics/infer_natural_mortality.py
mortality_read_infer_plot_app(country, version, gender, min_year, max_year, save_data=False, other_csv_filename=None, img_dir=None)
Using the 'version' and 'gender', select the UN World Population mortality data file. Extract the mortality data from the selected file for the given country and plot both the raw data and the inferred data (without HIV deaths). The plot will have a plot for each age where the data in the plot shows the rate per year for that age group. The label shows the minimum age of the band. This means that the age range being represented is from this value to the next largest age that is plotted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country
|
str
|
The name of the country to be extracted. It must match exactly to the country name used in the referenced spreadsheet. |
required |
version
|
str
|
The year/version of the indicated spreadsheet. Each year has a slightly different format. Supported versions are 2012, 2015, 2019, 2024 |
required |
gender
|
str
|
The gender of the data to be extracted. Possible values are 'male' and 'female'. |
required |
min_year
|
int
|
The start year of the interval to fit the data to. |
required |
max_year
|
int
|
The end year of the interval to fit the data to. |
required |
save_data
|
bool
|
If true (default is False), two YearAgeRate CSV formatted files are output into the current directory. The files are: 'raw_mortality_year_age_rate.csv' and 'mortality_minus_hiv_year_age_rate.csv'. |
False
|
other_csv_filename
|
str
|
If the filename is defined, it reads an expected YearAgeRate CSV file and plots it with the raw and inferred data from the spreadsheet. This allows the user to plot other mortality data (i.e. older versions) with the new data. |
None
|
img_dir
|
str
|
If this is defined, the images are saved to this directory. If not defined, the images are displayed in a window. |
None
|
Return
No return