Across all source fields · requires natality 0.7.0
Follow a concept across changing names
Browse the complete concept catalog, inspect each annual source, and follow the comparisons from 2000→2001 through 2023→2024. A name can change while its concept continues; a name can also be reused for a different purpose.
library(natality)
# These bundled catalogs work without downloading birth records.
catalog <- natality_concepts()
subset(catalog, grepl("hypertension", label, ignore.case = TRUE))
natality_crosswalk("tobuse", years = 2000:2024)
natality_transitions("tobuse", years = 2001:2024)
# Explicitly illustrated source codes, not an extract or an estimate.
# In 2002 TOBACCO is the clinical item; TOBUSE is its reporting flag.
example <- data.frame(TOBACCO = c("1", "2", "9"),
TOBUSE = c("1", "1", "1"))
aligned <- align_natality(example, year = 2002, concepts = "tobuse")
aligned[c("TOBACCO", "TOBUSE", "nat_tobuse_source_code",
"nat_tobuse_source_field", "nat_tobuse_rule_id")]
stopifnot(identical(aligned$TOBACCO, example$TOBACCO))
# Alignment retains literal annual codes. It does not turn them into
# common yes/no values or apply reporting-population restrictions.
# Inspect exact annual definitions before analyzing real records.
natality_codebook("TOBACCO", years = 2002)
natality_codebook("TOBUSE", years = 2003)align_natality() preserves literal codes under a common concept identifier and records the source field and rule version. If a year contains multiple source variants, choose one explicitly. Use standardize_natality() only for its separately documented bounded transformations. Neither a connected name nor an unchanged code establishes equal measurement or reporting coverage.
Worked example 01
Reproduce monthly birth counts
A complete first workflow: read one annual source, select U.S.-resident births, check the month codes, reconcile the counts and save provenance. The code executes on real records when run in R; this page does not simulate output.
library(natality)
# The first read downloads the annual file. Later reads reuse it.
births <- read_natality(
2024, vars = "DOB_MM", population = "us_residents"
)
# Count every released month; fail if any record is outside 01-12.
month_codes <- sprintf("%02d", 1:12)
stopifnot(all(births$DOB_MM %in% month_codes))
monthly <- data.frame(
month = month.abb,
births = as.integer(table(factor(births$DOB_MM, levels = month_codes)))
)
stopifnot(sum(monthly$births) == nrow(births))
print(monthly)
# Keep the annual source identity with the exported table.
write.csv(monthly, "natality_2024_monthly_births.csv", row.names = FALSE)
saveRDS(attr(births, "natality_provenance"), "natality_2024_provenance.rds")
natality_cite(2024)Months have different lengths. These are birth counts, not daily rates or seasonally adjusted estimates.
Worked example 02 · requires natality 0.6.0
Derive low birthweight and preserve age intervals
The opt-in core adds standardized values and explicit status fields. This calculation uses known recorded weight, with unknown weight kept outside the analytical denominator.
library(natality)
x <- read_natality(
2024, vars = c("DBWT", "MAGER"), population = "us_residents"
)
z <- standardize_natality(x, 2024,
concepts = c("birthweight", "low_birthweight", "maternal_age")
)
# Original columns remain; inspect why a new value is missing.
stopifnot(identical(x$DBWT, z$DBWT), identical(x$MAGER, z$MAGER))
table(z$nat_birthweight_status, useNA = "ifany")
numerator <- sum(z$nat_low_birthweight, na.rm = TRUE)
denominator <- sum(!is.na(z$nat_low_birthweight))
data.frame(numerator, denominator, percent = 100 * numerator / denominator)
# Grouped age endpoints are intervals, never invented exact ages.
unique(z[c("MAGER", "nat_maternal_age_years", "nat_maternal_age_lower",
"nat_maternal_age_upper", "nat_maternal_age_granularity")])Internal reconstruction on all 3,628,934 resident records gives 308,966 low-birthweight births among 3,625,941 births with known eligible weight; 2,993 have unknown weight. Independent scientific reproduction is still pending.
The current eight-concept core covers 2000–2024. It preserves native data and grouped age bounds; it does not automatically harmonize gestation or resolve undocumented historical missing codes.
Worked example 03 · requires natality 0.6.1
Follow gestational diabetes across source names
RF_GEST in 2004–2013 and RF_GDIAB in 2014–2024 record the same named condition. The explicit transformation uses the annual field, reporting flag and historical certificate indicator. It adds a separate logical value and status columns while retaining the original data.
library(natality)
# Change the year to use its documented native field and dependencies.
year <- 2013
concept <- natality_concepts("gestational_diabetes")
spec <- concept$annual_contracts[[as.character(year)]]
stopifnot(identical(spec$availability, "available"))
vars <- unlist(spec[c("source_field", "reporting_flag", "certificate_field")],
use.names = FALSE)
x <- read_natality(year, vars = vars, population = "us_residents")
z <- standardize_natality(x, year, concepts = "gestational_diabetes")
# Source answers and reporting eligibility remain separate.
table(z$nat_gestational_diabetes_source_status,
z$nat_gestational_diabetes_eligibility_status, useNA = "ifany")
data.frame(
year = year,
reported_yes = sum(z$nat_gestational_diabetes, na.rm = TRUE),
eligible_known = sum(!is.na(z$nat_gestational_diabetes))
)
# Reporting populations change across years; review coverage before pooling.The first read downloads the complete annual file. Only eligible reported yes/no responses contribute to the known denominator. Unknown, not-on-certificate, nonreporting and unavailable states remain distinguishable. Earlier combined diabetes fields cannot identify gestational diabetes separately; 2000–2003 receive an unavailable status. This mapping does not establish a nationally comparable trend across changing reporting areas.
Configure your own annual extract
The extract builder produces an R script, data dictionary, citations and a saved specification for the selected annual native fields. Review the eligibility criteria before running it.
Before an outcome analysis
- Choose the intended population, measurement and denominator.
- Inspect annual source codes, reporting flags and unresolved questions.
- Keep unknown, nonreporting and out-of-range records distinguishable.
- Reproduce an official statistic, then a meaningful stratum.
- Assess changes across years before pooling or fitting a trend.
The trend workspace identifies the source behind each displayed series. Independent scientific reproduction remains a separate release requirement.