Closed tiernanmartin closed 2 months ago
Hi @tiernanmartin! Apologies for the slow response and thank you for the message!
You are absolutely correct. The geo_bias_data
by default does not output any racial/ethnic demographic results. However, if you are interested in getting geographic disparity scores using a population not included in the tool, the tool can handle this functionality by taking a supplemental geographic dataset. The description/example code in our documentation shows code syntax from the sedtR::call_sedt_api()
function.
To expand a bit on that information, I suspect your workflow should be something like:
sedtR::call_sedt_api()
function and specify optional arguments geographic_file_path
, geographic_geo_id_column
and geographic_columns()
referencing the data you pulled in step 2.geo_bias_data
objectThis workflow works for me:
library(sedtR)
library(tidyverse)
library(tidycensus)
#Step 1a: Identify point resource data
download.file(
"https://equity-tool-api.urban.org/sample-data/minneapolis_bikes.csv",
destfile = "bikes.csv")
#Step 1b: determine appropriate geographic scale:
# Scale is the CITY because Minneapolis is a city
# Step 2: Get racial/ethnic population. In this case, we will do non-Hispanic Black population
minneapolis_black_pop <- tidycensus::get_acs(
geography = "tract",
variables = "B02001_003",
state = "MN",
place = "Minneapolis",
year = 2022,
geometry = FALSE) |>
rename(black_pop_estimate = estimate,
black_pop_moe = moe)
write_csv(minneapolis_black_pop, "minneapolis_black_pop.csv")
#Step 3: Call API with geographic supplemental data arguments
sedt_results <- sedtR::call_sedt_api(
resource_file_path = "bikes.csv",
resource_lat_column = "lat",
resource_lon_column = "lon",
geographic_file_path = "minneapolis_black_pop.csv",
geographic_geo_id_column = "GEOID",
geographic_columns = list(
black_pop_estimate = "black_pop_moe")
)
geo_bias <- sedt_results$geo_bias_data
#Step 4: Visualize geographic disparity scores
map <- sedtR::create_map(sedt_results$geo_bias_data,
interactive = FALSE,
save_map = FALSE,
col_to_plot = "diff_black_pop_estimate_geographic")
Perfect! I can't believe I didn't think to do that. Thanks for going the extra mile by providing a reproducible example.
I would like to be able to display racial demographic disparity scores in a choropleth map, but the
geo_bias_data
object does not include these variables. Can this information be made available to the user?