[R-sig-Geo] Calculating median age for a group of US census blocks?

Jeff Boggs jbogg@ @end|ng |rom brocku@c@
Mon Aug 7 20:53:05 CEST 2023


Responses to your questions:
Q1: No. It is not mathematically valid, sadly.

Q2: I do not know, but your intuition that this is a possible solution is correct.

I don't use US Census data anymore, but suspect that the data exists. Whether they are publicly-available is a different question. I suspect, though, that block level age-sex cohort in five-year intervals is available, given this is the usual ingredient for a population pyramid. That data could be used to calculate a less exact median, if you make some simplifying assumptions.

Best regards,
Jeff


________________________________________
From: R-sig-Geo <r-sig-geo-bounces using r-project.org> on behalf of Kevin Zembower via R-sig-Geo <r-sig-geo using r-project.org>
Sent: Monday, August 7, 2023 14:33
To: r-sig-geo using r-project.org
Subject: [R-sig-Geo] Calculating median age for a group of US census blocks?

Hello, all,

I'd like to obtain the median age for a population in a specific group
of US Decennial census blocks. Here's an example of the problem:

## Example of calculating median age of population in census blocks.
library(tidyverse)
library(tidycensus)

counts <- get_decennial(
     geography = "block",
     state = "MD",
     county = "Baltimore city",
     table = "P1",
     year = 2020,
     sumfile = "dhc") %>%
     mutate(NAME = NULL) %>%
     filter(substr(GEOID, 6, 11) == "271101" &
            substr(GEOID, 12, 15) %in% c(3000, 3001, 3002)
            )

ages <- get_decennial(
     geography = "block",
     state = "MD",
     county = "Baltimore city",
     table = "P13",
     year = 2020,
     sumfile = "dhc") %>%
     mutate(NAME = NULL) %>%
     filter(substr(GEOID, 6, 11) == "271101" &
            substr(GEOID, 12, 15) %in% c(3000, 3001, 3002)
            )

I have two questions:

1. Is it mathematically valid to multiply the population of a block by
the median age of that block (in other words, assign the median age to
each member of a block), then calculate the median of those numbers for
a group of blocks?

2. Is raw data on the ages of individuals available anywhere else in the
census data? I can find tables such as P12, that breaks down the
population by age ranges or bins, but can't find specific data of counts
per age in years.

Thanks for your advice and help.

-Kevin

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo using r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list