Title: | District level estimation of age-specific fertility |
---|---|
Description: | This package estimates district-level estimates of age-specific fertility from nationally representative household survey data. |
Authors: | Oli Stevens [aut, cre] |
Maintainer: | Oli Stevens <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.666 |
Built: | 2024-12-13 04:59:20 UTC |
Source: | https://github.com/mrc-ide/dfertility |
Aggregate district level populations to all levels of area hierarchy
area_populations(population, areas_wide, project, naomi_level)
area_populations(population, areas_wide, project, naomi_level)
population |
Age/sex/space/time stratified population |
areas_wide |
Area hierarchy in wide format |
Aggregate a dataframe of survey clusters geolocated to an administrative to any higher administrative level
assign_cluster_area(clusters, areas_wide, area_level)
assign_cluster_area(clusters, areas_wide, area_level)
clusters |
Dataframe of geolocated survey clusters |
areas_wide |
Area hierarchy in wide format |
area_level |
Integer referring to administrative level, where 0 is national, 1 is provincial etc. |
Dataframe list of clusters by administrative area, one list item per survey
Calculate fertility rates from DHS, MIS, AIS data
calculate_dhs_fertility(iso3, surveys, clusters, areas_wide)
calculate_dhs_fertility(iso3, surveys, clusters, areas_wide)
Calculate fertility rates from MICS data
calculate_mics_fertility(iso3, mics_wm, mics_births_to_women)
calculate_mics_fertility(iso3, mics_wm, mics_births_to_women)
Download MICS surveys
create_surveys_mics(iso3, mics_indicators)
create_surveys_mics(iso3, mics_indicators)
iso3 |
ISO3 code |
Filter MICS household, women, and birth history datasets to key variables, and rename to ensure consistent column names between surveys
filter_mics(dat, mics_indicators, survey_id_i)
filter_mics(dat, mics_indicators, survey_id_i)
Fit TMB model
fit_sample_tmb(data, par, random)
fit_sample_tmb(data, par, random)
Create area hierarchy dataframes in the Naomi package format. The function will always return the area hierarchy in long format, with arguments additionally to return full and wide hierarchies
get_areas(iso3_current, naomi_data_path, full = FALSE, wide = TRUE)
get_areas(iso3_current, naomi_data_path, full = FALSE, wide = TRUE)
iso3_current |
A string of one or more ISO-3 codes |
naomi_data_path |
A path to directory containing input data files |
full |
Boolean to return the full area heirarchy |
wide |
Boolean to return the area hierarchy in wide format |
Returns a dataframe of area boundaries
get_boundaries(iso3_current, naomi_data_path)
get_boundaries(iso3_current, naomi_data_path)
iso3_current |
A string of one or more ISO-3 codes |
naomi_data_path |
A path to directory containing input data files |
Extract area, population, boundary files from target directory
get_input_files(iso3_current, naomi_data_path)
get_input_files(iso3_current, naomi_data_path)
iso3_current |
A string of one or more ISO-3 codes |
naomi_data_path |
A path to directory containing input data files |
A named list of file paths
Returns a dataframe of population by district, five year age group, and sex
get_populations(iso3_current, naomi_data_path)
get_populations(iso3_current, naomi_data_path)
iso3_current |
A string of one or more ISO-3 codes |
naomi_data_path |
A path to directory containing input data files |
Join individual recode survey datasets by area
ir_by_area(ir, area_list, n, total)
ir_by_area(ir, area_list, n, total)
ir |
Individual recode survey dataset |
area_list |
List of areas |
Join household datasets with area hierarchy
join_survey_areas(fertility_mics_data, areas, warn = FALSE)
join_survey_areas(fertility_mics_data, areas, warn = FALSE)
Neighbor list
make_adjacency_matrix(areas, model_level)
make_adjacency_matrix(areas, model_level)
Transform survey datasets into inputs for calc_asfr
make_asfr_inputs(mics_survey_areas, mics_survey_data)
make_asfr_inputs(mics_survey_areas, mics_survey_data)
Create model frames and aggregation matrices for TMB model.
make_model_frames_batch(lvl_map, population, asfr, areas_list, project = 2020)
make_model_frames_batch(lvl_map, population, asfr, areas_list, project = 2020)
population |
Age/sex/space stratified population |
asfr |
ASFRs by district and time |
areas_list |
List of area files |
project |
Model will by default produce estimates up to year of last survey. Integer projection year if desired, else FALSE |
lvl |
Dataframe of district and province levels |
Create model frames and aggregation matrices for TMB model.
make_model_frames_dev( iso3, population, asfr, areas, naomi_level, project = 2020 )
make_model_frames_dev( iso3, population, asfr, areas, naomi_level, project = 2020 )
iso3 |
iso3 code for country |
population |
Age/sex/space stratified population |
asfr |
ASFRs by district and time |
areas |
Area hierarchy |
naomi_level |
Area level to produce estimates at |
project |
Model will by default produce estimates up to year of last survey. Integer projection year if desired, else FALSE |
Make random walk structure matrices
make_rw_structure_matrix(x, order, adjust_diagonal = TRUE)
make_rw_structure_matrix(x, order, adjust_diagonal = TRUE)
x |
Matrix size |
order |
Random walk order |
adjust_diagonal |
Add 1E-6 to the matrix diagonal to make the matrix proper. Default = TRUE |
Sample TMB
sample_tmb( fit, nsample = 1000, rng_seed = NULL, random_only = TRUE, verbose = FALSE )
sample_tmb( fit, nsample = 1000, rng_seed = NULL, random_only = TRUE, verbose = FALSE )
Convert lists by survey to lists by dataset type
transform_mics(mics_survey_data, mics_indicators)
transform_mics(mics_survey_data, mics_indicators)