From ae21c79de577cd388ec7d5bd46eb4cc6f6988a55 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 18:10:48 +0000 Subject: [PATCH] docs: explain survey years where vignettes compare governments (#77) NEWS.md gains a development-version entry for fiscal_period, cog_fiscal_periods() and cog_survey_year(). total-spending.Rmd shows that its Florida rollup mixes a June 30 state (July 2019 to June 2020) with two September 30 counties (October 2018 to September 2019) under the same 2020. coverage-counters.Rmd counts the FY2012 fiscal year ends of Georgia cities (273 December 31, 196 June 30, 36 September 30) and what months they cover. population-denominators.Rmd notes that each cohort year is a survey year. The first two chunks run against the bundled fixture. Refs #77 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Qbe6u2h83wgZdTgJgE4Xh5 --- NEWS.md | 34 +++++++++++++++++++++++++++ vignettes/coverage-counters.Rmd | 20 ++++++++++++++++ vignettes/population-denominators.Rmd | 6 +++++ vignettes/total-spending.Rmd | 17 ++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/NEWS.md b/NEWS.md index ea1282e..ed1ed00 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,37 @@ +# uscogdata (development version) + +## Fiscal-year periods for each row + +`year` is the Census survey year, and a survey year covers different months for +different governments. Census files a government's fiscal year under survey year Y +when it ended between July 1 of Y-1 and June 30 of Y. For a county, city or township, +"2017" means July 2016 to June 2017 with a June 30 year end, October 2015 to +September 2016 with a September 30 year end, and January to December 2016 with a +December 31 year end. + +`cog_spending()`, `cog_revenue()` and `cog_balances()` gain `fiscal_period = FALSE`. +With `fiscal_period = TRUE`, every row gains three columns at the end: +`fiscal_year_end`, an MMDD integer such as `630`, and `period_start` and `period_end`, +the first and last day the row covers. They come from that government-year's own +fiscal year end, so a change of fiscal year is respected, and they are `NA` where the +corpus has no value. The provenance gains `transformations$fiscal_period`. The default +returns the same columns and provenance as before. + +```r +cog_spending("121011212191", years = 2020, category = "Police", fiscal_period = TRUE) +``` + +`cog_fiscal_periods(govid, years)` returns the months each survey year covers for +each government. `cog_survey_year(govid, date)` returns the survey year whose period +contains a date, which places an event against the corpus's `year`. + +State governments follow a different rule: survey year Y holds the fiscal year ending +in calendar year Y. It changes the months for three states, Alabama and Michigan +(September 30) and Texas (August 31). Census's 2004 and 2006 technical documentation +lists them as exceptions to the June 30 window, and the published corpus agrees for +survey year 2020. The same documentation lists the District of Columbia, so it gets +the state rule too, although the data has not confirmed it. + # uscogdata 0.4.0 ## Cohorts can be named by predicate, not just by id diff --git a/vignettes/coverage-counters.Rmd b/vignettes/coverage-counters.Rmd index a3ef1c2..eea3a29 100644 --- a/vignettes/coverage-counters.Rmd +++ b/vignettes/coverage-counters.Rmd @@ -287,6 +287,26 @@ rows. calendar. Read `n_units_collected` to see how complete a year is: in FY2012, a census year, the fixture has spending rows for 534 of its 566 Georgia cities. +# Survey years and fiscal years + +The counters count governments per survey year, and a survey year covers different +months for different governments. Census files a fiscal year under survey year Y when +it ended between July 1 of Y-1 and June 30 of Y. Count the fiscal year ends of the +Georgia cities in FY2012: + +```{r} +fy2012 <- cog_fiscal_periods(ga_cities$canonical_govid, years = 2012) +table(fy2012$fiscal_year_end, useNA = "ifany") +``` + +In FY2012, 273 of the 566 Georgia cities close their books on December 31, 196 on +June 30 and 36 on September 30. Their FY2012 figures cover calendar 2011, July 2011 to +June 2012, and October 2010 to September 2011. The 31 cities with no value have no rows +in the corpus that year or no recorded year end. A city with a July 31 year end has an +FY2012 that ends on July 31, 2011, 11 months before the June cities' FY2012 ends. +Pass `fiscal_period = TRUE` to `cog_spending()` to see each row's months, and see +`?cog_fiscal_periods` for the rule. + # Summary - `n_units_expected` is the number of governments you named, or the number of peers diff --git a/vignettes/population-denominators.Rmd b/vignettes/population-denominators.Rmd index 1ea7f95..c1271e2 100644 --- a/vignettes/population-denominators.Rmd +++ b/vignettes/population-denominators.Rmd @@ -59,6 +59,12 @@ out <- purrr::map_dfr(years, function(y) { Each row in `out` has `cohort_year == year`, so a faceted plot shows cohort drift directly. +Each `year` is a Census survey year, which covers different months for different +governments: a city with a June 30 fiscal year end and one with a December 31 year end +report figures six months apart under the same `year`. Pass `fiscal_period = TRUE` to +`cog_spending()` to get each row's `period_start` and `period_end`, and see +`?cog_fiscal_periods` for the rule. + # Future direction `pop_source` is a column on the result, not a fixed value, so adding a new denominator (PEP from tidycensus, decennial counts, ACS time-series) is a join change rather than an API change. A future release may add `cog_spending(..., pop_source = "pep")` for users who need a single externally-audited series. diff --git a/vignettes/total-spending.Rmd b/vignettes/total-spending.Rmd index 78a8319..57c32a9 100644 --- a/vignettes/total-spending.Rmd +++ b/vignettes/total-spending.Rmd @@ -132,6 +132,23 @@ ga_state <- cog_spending( ga_state ``` +The rollup also mixes fiscal calendars. `year` is the Census survey year, and Census +files a fiscal year under survey year Y when it ended between July 1 of Y-1 and +June 30 of Y. `cog_fiscal_periods()` shows the months each government's 2020 covers: + +```{r} +cog_fiscal_periods( + c("120000226351", "121011212191", "121099101897"), # Florida, Broward, Palm Beach + years = 2020 +) +``` + +Florida's state government closes its books on June 30, so its 2020 covers July 2019 +to June 2020. Broward and Palm Beach counties close on September 30, so their 2020 +covers October 2018 to September 2019, and their figures end nine months before the +state's. Pass `fiscal_period = TRUE` to `cog_spending()` to get these columns on every +row, and see `?cog_fiscal_periods` for the rule and its exceptions. + Now the same rollup, but asking for `expenditure_concept = "total"`: ```{r, error = TRUE}