utility to calculate annually for EJSCREEN the updated ACS data available at only tract resolution (% disability & language detail)
Source:R/calc_blockgroupstats_from_tract_data.R
calc_blockgroupstats_from_tract_data.Rdutility to calculate annually for EJSCREEN the updated ACS data available at only tract resolution (% disability & language detail)
Arguments
- yr
endyear of ACS 5-year survey to use, inferred if omitted
- tables
ACS tract tables used for tract-derived indicators, typically
"B18101","C16001", and"B27010"for disability, detailed language, and health insurance.- formulas
default includes formulas for disability-related and language-related indicators calculated from tract-level ACS variables. This is a vector of string formulas.
- dropMOE
logical, whether to drop not retain the margin of error information for each ACS variable
- acs_raw
optional raw ACS table list or
bg_acs_rawpipeline object previously created bydownload_bg_acs_raw(). If supplied, no ACS download is performed for tract-resolution tables.- tract_weight_source
source for blockgroup-to-tract apportionment weights.
"decennial2020"uses 2020 Decennial Census population weights, matching the legacy EJSCREEN approach."acs"uses same-vintage ACS blockgroup population fromacs_rawor downloads it when needed.
Details
This is now typically orchestrated by calc_ejscreen_dataset() and the
staged pipeline recipe/config helpers documented in
data-raw/run_ejscreen_pipeline_*.R.
Relies on the function get_acs_new() which is available from the package ACSdownload (on github) as ACSdownload::get_acs_new()
Needs Census API key for tidycensus::get_decennial().
Takes some time to download data for every State!
First get tract counts, then apportion every tract count into blockgroup
counts (the tract count times the blockgroup's share of the tract
population, bgwt), then carry each tract's percentages onto its
blockgroups.
Apportioning applies to the language counts from C16001 (lan_universe,
lan_spanish, etc.) exactly as it does to disability and health insurance.
map_headernames marks all of these as "sum of counts", so
doaggregate() and calc_acs_by_geography() add them up across
blockgroups. A tract total repeated on every blockgroup would be counted
once per blockgroup, about three times over, in every buffer, county, and
state total (issue EJAM#596). Apportioned counts add back up to the tract
total, to rounding, which is also how EPA's EJScreen block group layer
reports language counts.
Percentages such as pctlan_spanish are calculated at tract level and
repeated on each blockgroup in the tract. That equals the ratio of the
apportioned counts wherever bgwt > 0, and it keeps the tract rate on
zero-population blockgroups instead of reporting 0 there, the same
convention pctdisability uses. Apportioned counts are rounded to whole
persons after the percentages are set.
For ACS 2022 and later, Connecticut ACS tract FIPS use planning-region
county equivalents while 2020 Decennial blockgroup FIPS use the older county
equivalents. When tract_weight_source = "decennial2020" and acs_raw is
available, the function detects this mismatch and remaps the 2020
Decennial weights to the same ACS blockgroup suffixes, using same-vintage
ACS blockgroup population weights only for ambiguous or unmatched cases.