Title: | The first90 model |
---|---|
Description: | Implements the Shiny90 model for estimating progress towards the UNAIDS "first 90" target for HIV awareness of status in sub-Saharan Africa. |
Authors: | Jeffrey Eaton [aut, cre] , Mathieu Maheu-Giroux [aut], Katia Giguère [aut], Roma Bhatkoti [aut] |
Maintainer: | Jeffrey Eaton <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.7.1 |
Built: | 2024-12-18 06:11:24 UTC |
Source: | https://github.com/mrc-ide/first90release |
Add incidences corresponding to state space
add_ss_indices(dat, ss)
add_ss_indices(dat, ss)
dat |
a data.frame with particular columns coded in particular ways |
ss |
state space definition (fp$ss) |
## Not run: data(survey_hts) dat <- subset(survey_hts, survey_hts$country == "Malawi" & outcome == "evertest") df <- add_ss_indices(dat, fp$ss) ## End(Not run)
## Not run: data(survey_hts) dat <- subset(survey_hts, survey_hts$country == "Malawi" & outcome == "evertest") df <- add_ss_indices(dat, fp$ss) ## End(Not run)
ART coverage among age 15-49
artcov15to49(mod, sex = "both")
artcov15to49(mod, sex = "both")
Calculate ASFR from TFR and fertility distribution
calc_asfr(tfr, asfd)
calc_asfr(tfr, asfd)
tfr |
vector of annual TFR values |
asfd |
array of proportion of births by 5 year age group 15-49 |
array of age-specific fertility rate by single-year of age 15-49.
Combine PJNZ inputs
combine_inputs(lst)
combine_inputs(lst)
lst |
a list of inputs, each returned from extract_pjnz() |
Beers coefficients to distribute from 5-year to single-year of age
create_beers(n5yr)
create_beers(n5yr)
Create HIV testing rates from parameter inputs
create_hts_param(theta, fp)
create_hts_param(theta, fp)
This function creates two arrays hts_rate
and diagn_rate
.
The hts_rate
array summarizes HIV testing rates for the HIV negative population stratified by:
HIV aggregated age groups (hAG: 1-9)
sex (1 = male; 2 = female)
testing history (1 = never tested; 2 = previously tested negative)
year
Array diagn_rate
summarizes HIV testing rates for the HIV positive population stratified by:
CD4 stage (hDS: 1-7)
HIV age group (hAG: 1-9)
sex (1 = male; 2 = female)
testing and treatment history (1 = never tested; 2 = previously tested negative; 3 = diagnosed, not treated; 4 = on ART)
year
This function calculates proportion diagnosed among the HIV positive population stratified by age group, sex, HIV status, and year.
diagnosed(mod, fp, df, VERSION = "C")
diagnosed(mod, fp, df, VERSION = "C")
mod |
simulation model output |
fp |
simulation model parameter inputs |
df |
a data.frame with indices for prediction, see Details. |
Age groups are specified in terms of aggregate HIV age groups: 15-16, 17-19, 20-24, ..., 45-49, 50+. Another function could be added to handle other age groups if needed, with additional computational complexity.
The argument df must contain the following columns:
haidx: HIV age group (1 = 15-16, 2 = 17-19, 3 = 20-24, ..., 8 = 45-49, 9 = 50+)
sidx: sex (1 = male, 2 = female, 0 = both)
yidx: year index
hagspan: number of HIV age groups to span
a vector
## Not run: data(survey_hts) dat <- subset(survey_hts, country == "Malawi" & outcome == "aware") df <- add_ss_indices(dat, fp$ss) df$pred <- diagnosed(mod, fp, df) ## End(Not run)
## Not run: data(survey_hts) dat <- subset(survey_hts, country == "Malawi" & outcome == "aware") df <- add_ss_indices(dat, fp$ss) df$pred <- diagnosed(mod, fp, df) ## End(Not run)
This function calculates proportion of ever tested among a population stratified by age group, sex, HIV status, and year.
evertest(mod, fp, df, VERSION = "C")
evertest(mod, fp, df, VERSION = "C")
mod |
simulation model output |
fp |
simulation model parameter inputs |
df |
a data.frame with indices for prediction, see Details. |
Age groups are specified in terms of aggregate HIV age groups: 15-16, 17-19, 20-24, ..., 45-49, 50+. Another function could be added to handle other age groups if needed, with additional computational complexity.
The argument df must contain the following columns:
haidx: HIV age group (1 = 15-16, 2 = 17-19, 3 = 20-24, ..., 8 = 45-49, 9 = 50+)
sidx: sex (1 = male, 2 = female, 0 = both)
hvidx: HIV status (1 = negative, 2 = positive, 0 = all)
yidx: year index
hagspan: number of HIV age groups to span
a vector
## Not run: data(survey_hts) dat <- subset(survey_hts, country == "Malawi" & outcome == "evertest") df <- add_ss_indices(dat, fp$ss) df$pred <- evertest(mod, fp, df) ## End(Not run)
## Not run: data(survey_hts) dat <- subset(survey_hts, country == "Malawi" & outcome == "evertest") df <- add_ss_indices(dat, fp$ss) df$pred <- evertest(mod, fp, df) ## End(Not run)
Internal helper functions
exists_dptag(dp, tag, tagcol = 1)
exists_dptag(dp, tag, tagcol = 1)
Extract outputs from PJNZ needed for first90 model
extract_pjnz(pjnz = NULL, dp_file = NULL, pjn_file = NULL)
extract_pjnz(pjnz = NULL, dp_file = NULL, pjn_file = NULL)
pjnz |
filepath to PJNZ file |
dp_file |
filepath to a .DP file |
pjn_file |
filepath to a .PJN file |
a list
Extract AIM module parameters
get_dp_frr(dp, proj_years)
get_dp_frr(dp, proj_years)
Get sex ratio at birth
get_dp_srb(dp, proj_years)
get_dp_srb(dp, proj_years)
Get mortality probability (Sx) from Spectrum DP file
get_dp_Sx(dp, proj_years)
get_dp_Sx(dp, proj_years)
This function extracts Sx for ages 0:79 and 80+. Spectrum calculates a separate Sx for age 80. The population projection model in EPP-ASM needs to be updated to handle this.
Get age-specific fertility rate by single-year
get_dp_tfr(dp, proj_years)
get_dp_tfr(dp, proj_years)
Extract arrays from Spectrum DP file
get_dp_totpop(dp, proj_years)
get_dp_totpop(dp, proj_years)
Get country name from parsed PJN
get_pjn_country(pjn)
get_pjn_country(pjn)
pjn |
parsed PJN file |
pjn
should be via first90_read_csv_character(pjn_file)
Get subnational region from parsed PJN
get_pjn_region(pjn)
get_pjn_region(pjn)
pjn |
parsed PJN file |
pjn
should be via first90_read_csv_character(pjn_file)
Number of new diagnoses by age and sex
number_diagnoses(mod, fp, df, VERSION = "R")
number_diagnoses(mod, fp, df, VERSION = "R")
A data frame reporting new diagnoses in two ways:
Approximated from the testing rates and mid-year populations
as in the function number_tests()
.
Based on the number of new diagnoses recorded in each model time step.
The column late_diagnoses
reports the number who are initiated to ART
directly from the undiagnosed population.
The two approaches are largely for debugging purposes to understand the implications of the model choices.
Calculate number adn proportion of retests conducted or number tested by year funtion based on number test in the outputs.R script
number_retests(mod, fp, df)
number_retests(mod, fp, df)
mod |
model output of class 'eppasm' |
fp |
parameter inputs (class 'specfp') |
df |
a data.frame with indices for prediction. See |
Number of tests (or number tested in past 12 months) are approximated by mid-year counts and annual testing rates within each stratum.
a data.frame consisting of the number of tests, and population size corresponding to rows of df
Calculate number of tests conducted or number tested by year
number_tests(mod, fp, df, tested12m = FALSE, VERSION = "C")
number_tests(mod, fp, df, tested12m = FALSE, VERSION = "C")
mod |
model output of class 'eppasm' |
fp |
parameter inputs (class 'specfp') |
df |
a data.frame with indices for prediction. See |
Number of tests (or number tested in past 12 months) are approximated by mid-year counts and annual testing rates within each stratum.
a data.frame consisting of the number of tests, number tested in the past 12 months, and population size corresponding to rows of df
Create model inputs from Spectrum PJNZ
prepare_inputs(pjnzlist)
prepare_inputs(pjnzlist)
pjnzlist |
a vector of PJNZ file names to aggregate |
The aggregation makes a number of assumptions:
Progression parameters are the same in all files, and values frome the first file are used.
Special populations ART eligibility is the same in all files.
pjnzlist <- list.files("~/Documents/Data/Spectrum files/2018 final/SSA/", "CotedIvoire.*PJNZ$", full.names=TRUE, ignore.case=TRUE) pjnzlist <- "~/Documents/Data/Spectrum files/2018 final/SSA/Malawi_2018_version_8.PJNZ"
pjnzlist <- list.files("~/Documents/Data/Spectrum files/2018 final/SSA/", "CotedIvoire.*PJNZ$", full.names=TRUE, ignore.case=TRUE) pjnzlist <- "~/Documents/Data/Spectrum files/2018 final/SSA/Malawi_2018_version_8.PJNZ"
Create model inputs from aggregated Spectrum PJNZ
prepare_inputs_from_extracts(pjnz_in)
prepare_inputs_from_extracts(pjnz_in)
pjnz_in |
a list of outputs from extract_pjnz |
Process survey data on hiv testing behaviors
select_hts(survey_hts, cnt, age_group)
select_hts(survey_hts, cnt, age_group)
Process programmatic data on number of tests
select_prgmdata(prgm_dat, cnt, age_group)
select_prgmdata(prgm_dat, cnt, age_group)
Simulate EPP-ASM model
simmod(fp, VERSION = "C")
simmod(fp, VERSION = "C")
Table to write CSV outputs for Spectrum
spectrum_output_table(mod, fp)
spectrum_output_table(mod, fp)
Presently this returns point estimates for age 15+ population by sex:
Number PLHIV,
Ever tested among PLHIV
Aware of HIV+ status
On ART
PLHIV is mid-year estimate. All other outcomes are end of year estimate.
a data.frame to write to CSV file for ingestion into Spectrum
## Not run: write.csv(spectrum_output_table(mod, fp), "~/Downloads/Malawi-shiny90-example-output.csv", row.names = FALSE) ## End(Not run)
## Not run: write.csv(spectrum_output_table(mod, fp), "~/Downloads/Malawi-shiny90-example-output.csv", row.names = FALSE) ## End(Not run)
Function to present the survey data on shinny interface
svy_hts_interface(survey_hts, cnt, age_group = c("15-24", "25-34", "35-49"))
svy_hts_interface(survey_hts, cnt, age_group = c("15-24", "25-34", "35-49"))