heli-xu / findSVI

Calculate CDC/ATSDR Social Vulnerability Index
https://heli-xu.github.io/findSVI/
Other
2 stars 3 forks source link

Potential feature request: adding customized boundaries for SVI calculation #16

Closed usamabilal closed 3 months ago

usamabilal commented 6 months ago

It just occurred to me that people may have customized boundaries where they want to calculate the SVI. An example would be the Philadelphia Neighborhoods computed by PHMC and used by the UHC in the health of the city report. These are nested in tracts (it means each neighborhood is cleanly composed of 2010 tracts) so it'd be easy to calculate the SVI at this level.

Two ways of going about this:

  1. input boundaries
  2. input a crosswalk

i'm tempted to say 2 makes more sense here, as it'd be easier to implement, and it'd accomodate ANY crosswalk that uses ANY defintiion at which the SVi can be calculated (e.g., groups of tracts, groups of ZCTAs, groups of counties, etc.).

heli-xu commented 6 months ago

It's a great idea! Thanks for opening the issue, Usama.

i'm tempted to say 2 makes more sense here, as it'd be easier to implement, and it'd accomodate ANY crosswalk that uses ANY defintiion at which the SVi can be calculated (e.g., groups of tracts, groups of ZCTAs, groups of counties, etc.).

I agree! And if spatial analysis is needed, we can join the tracts/ZCTA/counties boundaries using the crosswalk, or we could also support additional geometry info included in the crosswalk.

usamabilal commented 6 months ago

Great! While the example"I need" is using internal definitions, we could do an example with commuting zones https://sites.psu.edu/psucz/

heli-xu commented 6 months ago

That's a pretty cool site! Is there a preferred timeline that you'd like this proof-of-concept?

usamabilal commented 6 months ago

I dont really have one! So up to you..

heli-xu commented 6 months ago

I'll aim to do this by the end of April. Thanks again for the suggestion!

heli-xu commented 4 months ago

Hi Usama, here is a working example with the commuting zones.

It took a bit longer than expected because the census variable lists and calculation tables needed modifying for aggregating (adding up) the counts but not the percentages. At this point, the new feature works with 2020 data only, and I'll add the rest of the years in the coming days.

I'd appreciate it if someone from your team would like to test out the feature (installing from the github customized-boundaries branch), and please let me know if there is a year in particular other than 2020 that you'd like to have sooner. I'd also appreciate any suggestions/feedback on how the feature is implemented.

Thanks for your help!

usamabilal commented 4 months ago

Thanks Heli! Have you checked that after re-doing the percentages using the counts the results for a known unit are the same? <_ I SEE this in the validating with pseudo crosswalk. great! An alternative to getting counts is a weighted average using the denominator as the weights, but if you got the counts you dont really need that.

So if i'm understanding things right, people have to get the census data at level X with argument exp, and then use that in get_svi_x along with the crosswalk. The crosswalk should have the same ID name as the data from the census, right? (e.g., GEOID).

Couldnt this be done in a single wrapper? where you provide the base unit ("county") which would get fed to the get_census data, and the crosswalk too.

If I want someone to do this should we invite them to the repository? In that case it'd be good to have Hal (@hal-ch) here to construct the SVI for Philadelphia neighborhoods (aggregation of tracts).

heli-xu commented 4 months ago

Thanks for the quick feedback, Usama!

So if i'm understanding things right, people have to get the census data at level X with argument exp, and then use that in get_svi_x along with the crosswalk. The crosswalk should have the same ID name as the data from the census, right? (e.g., GEOID).

Yes that's right. The crosswalk should have ID columns "GEOID" (for census level X) and "GEOID2" (for customized level).

Couldnt this be done in a single wrapper?

That's true...I can try adding a wrapper, instead of having the extra argument in get_census_data() and another function.

If I want someone to do this should we invite them to the repository?

For users I don't think it's necessary, but it might be helpful for them to have the working example linked above as a reference (it's not included as a vignette in the package yet because the feature is still in a branch). To use the new feature, users can install the development version using devtools::install_github("heli-xu/findSVI@customized-boundaries").

Thanks again for the suggestions!

hal-ch commented 4 months ago

Hi @heli-xu,

I'm currently trying to calculate SVI for Philadelphia neighborhoods, and to do that, I need to get the tracts for Philadelphia from 2020. However, using the following code: findSVI::get_census_data(state = "PA", county = "Philadelphia", year = 2020, geography = "tract", geometry = TRUE, exp = TRUE) with the exp argument keeps giving me the error Error in load_tiger(url, tigris_type = "tract", ...) : unused argument (exp = TRUE).

The code above works without the exp argument but it seems like I would need that to used the get_svi_x function, right?

heli-xu commented 4 months ago

Hi Hal, did you install from the github branch (devtools::install_github("heli-xu/findSVI@customized-boundaries")? Current CRAN/github main doesn't have the new feature (exp argument), which looks like what the error message is about. The code you're using seems to be working on my end using the branch version.

hal-ch commented 4 months ago

I did install from the GitHub branch, so not sure what happened there. I reinstalled again just now and it seems that the exp argument is working!

heli-xu commented 3 months ago

Hi Usama and Hal, happy to share some updates in the new feature:

This is a post to validate find_svi_x() using a pseudo-crosswalk and comparing against CDC SVI (for the years that they're available).

For more details please see pull request #22, and I also just merged the branch into main, so now you can install from github directly.

Please let me know if you have any questions or come across any issues! I'd appreciate any feedback or suggestions from you.

usamabilal commented 3 months ago

Thanks @heli-xu ! @hal-ch were you able to calculate SVI for our CCUH units?