How phskc-apde/rads works
Purpose and Package Surface
RADS is an R package for standardized public-health analysis, customized for PHSKC APDE workflows. Its public interface is defined by NAMESPACE; package initialization and metadata reside in R/rads-package.R and R/zzz.R. Primary user-facing entry points include calculation, data/reference access, recoding, age standardization, and uncertainty functions.
Core Calculation Pipeline
calc() is the central estimation interface, with specialized survey handling in R/calc.R and R/calc.dtsurvey.R. It likely accepts analytic data and measure definitions, validates or normalizes inputs, selects an estimation path, and returns public-health metrics such as counts, rates, and uncertainty-aware estimates. Shared numerical and validation boundaries are in R/validation_utils.R, R/check_nan.R, and R/digits.R.
Data Access and Reference Boundary
The package separates analysis logic from source-data acquisition. Generic and domain-specific retrieval functions are organized in R/get_data.R, while population/reference-population access is in R/get_population.R and R/build_getpop_query.R. Bundled crosswalk reference data is shipped at data/ref_get_xwalk.rda, sourced from data-raw/ref_get_xwalk.csv. The README states current releases should operate without SQL Server or file-server permissions; formerly dependent access functionality has moved to private apde.data.
Recode and Data-Modeling Layer
RADS supports declarative transformations: recode specifications are parsed, converted into dictionaries/instructions, then applied to data through R/parse_recode_instructions.R, R/create_recode.R, and R/enact_recodes.R. R/data_modeler.R provides a higher-level data-modeling stage, likely coordinating variable definitions and transformations before analysis. This forms a distinct boundary between raw analytic inputs and metric calculation.
Domain-Specific Classification
Public-health domain logic is encapsulated rather than embedded in calc(). Hospitalization/CHARS classifications and validation are in R/chars_functions.R; mortality cause definitions, ICD cleanup, multicause handling, and validation are in R/death_functions.R. These modules prepare domain-specific numerator definitions and derived classifications for the shared calculation pipeline.
Statistical Adjustment and Inference
Age adjustment is an independent analysis stage in R/age_standardize.R, using reference populations from the retrieval layer. Uncertainty propagation is implemented in R/propagate_uncertainty.R, allowing downstream transformations to retain or compute uncertainty rather than treating estimates as scalar-only results. Additional shared computational functions are grouped in R/utilities.R.
Runtime, Dependencies, and Delivery
This is a conventional R package (DESCRIPTION, NAMESPACE) installable from GitHub with remotes::install_github() and loaded via library(rads). Reference datasets are built in or supplied by the separately installed rads.data package. Documentation and intended workflows are exposed through vignettes such as vignettes/calc.Rmd, vignettes/calculating_rates_with_rads.Rmd, and vignettes/leading_causes_of_death.qmd.
Main entry points: calc.R calc() · data_modeler.R Data modeler · age_standardize.R Age standardization · get_data.R Data retrieval
Components 18
Package Surface
- Exports · Defines the public package interface.
NAMESPACE - Package initialization
R/rads-package.R - Load hooks
R/zzz.R
Data & References
- Data retrieval · Generic and domain-specific source-data access.
R/get_data.R - Population retrieval
R/get_population.R - Population query builder
R/build_getpop_query.R - Bundled crosswalk
data/ref_get_xwalk.rda
Modeling & Domain Prep
- Recode parser
R/parse_recode_instructions.R - Recode dictionary builder
R/create_recode.R - Recode executor
R/enact_recodes.R - Data modeler · Coordinates variable definitions and transformations.
R/data_modeler.R - CHARS classification
R/chars_functions.R - Mortality classification · Cleans and classifies ICD and multicause definitions.
R/death_functions.R
Estimation & Inference
- calc() · Produces public-health counts, rates, and estimates.
R/calc.R - Survey estimation
R/calc.dtsurvey.R - Age standardization
R/age_standardize.R - Uncertainty propagation
R/propagate_uncertainty.R - Validation & numeric utilities
R/validation_utils.R
Connections 17
- Exports → calc(): exports
- Package initialization → Load hooks: initializes
- Data retrieval → Data modeler: supplies inputs
- Population query builder → Population retrieval: builds retrieval
- Bundled crosswalk → Data retrieval: reference lookup
- Recode parser → Recode dictionary builder: parsed instructions
- Recode dictionary builder → Recode executor: recode dictionary
- Recode executor → Data modeler: transformed variables
- Data modeler → calc(): analytic data
- CHARS classification → calc(): numerator classifications
- Mortality classification → calc(): cause definitions
- Validation & numeric utilities → calc(): validates inputs
- calc() → Survey estimation: selects survey path
- calc() → Age standardization: estimates for adjustment
- Population retrieval → Age standardization: reference population
- calc() → Uncertainty propagation: estimate inputs
- Age standardization → Uncertainty propagation: adjusted estimates