Joins a live births data frame with a neonatal deaths data frame and computes NMR (deaths per 1,000 live births). Uses a full join so that state-months with births but no reported deaths contribute an NMR of 0 rather than being silently dropped.
Arguments
- births
Data frame with live births. Must contain columns
state,monyear,value. Additional calendar columns (date,cal_year,month,month_num) are included in the join if present in both data frames.- deaths
Data frame with neonatal deaths. Same column requirements as
births.- treat_na_deaths_as_zero
Logical. If
TRUE(default), state-months where births exist but deaths areNAare treated as zero deaths (HMIS non-reporting). Set toFALSEto returnNANMR for those months instead.
Value
A data frame with columns: state, monyear, any shared
calendar columns, births, deaths, nmr (per 1,000 live births).
Rows where births are missing or zero return NA for nmr.
Examples
if (FALSE) { # \dontrun{
male <- get_hmis("Number of male live births", sector = "Total")
female <- get_hmis("Number of female live births", sector = "Total")
births <- dplyr::bind_rows(male, female) |>
dplyr::group_by(state, monyear) |>
dplyr::summarise(value = sum(value, na.rm = TRUE), .groups = "drop")
deaths <- get_hmis("Infant Deaths up to 4 weeks due to Sepsis",
sector = "Total"
)
nmr <- compute_nmr(births, deaths)
} # }