usamabilal / LE_Income_Inequalities_City

Income Inequalities in LE by City study
MIT License
0 stars 0 forks source link

Updates to dashboard (PN3) #8

Open alinasmahl1 opened 2 years ago

alinasmahl1 commented 2 years ago

Please update figure 1 so that the y axis includes zero for all outcomes. There's also a negative value for the top/bottom ratio and disparities for income based differences, which doesn't really make sense.

Please update figure 3 so that it's now showing the mean, sd, and cv -- see the code lines 299-409

ran-codes commented 2 years ago

Great job updating the manuscript 🍰 ! I will start working on updating the app, just some quick questions and comments:

Figure 1

Got it will. make sure all y-axis include 0.

Figure 3

Just confirming what you want here: we will replace the CBSA-level figure with regional-level plots of mean, sd and cv. In other words, we will remove the old figure and replace it with the new Figure 3?

Figure 1: Negative values

There's also a negative value for the top/bottom ratio and disparities for income based differences, which doesn't really make sense.

In this city (Mortgantown, WV - 34060) the Life expectancy is lower for decile 10 of income. I added a few lines of code you can run to check this (151-156 in https://github.com/usamabilal/LE_Income_Inequalities_City/commit/4dcba46e2f24cbd0820273a9209ed00fedd00de2)

image

For the other exception (I think you are talking about Hinseville, GA) which has a negative slope. I checked the raw data (158-164 in https://github.com/usamabilal/LE_Income_Inequalities_City/commit/cc9c816d15b68a550310f415ae3886f9ee356319) and the slope is indeed negative when using a linear model. image

alinasmahl1 commented 2 years ago

Thanks Ran!! For figure 3- yup, exactly. Please replace the current figure with the new figure, but with the larger set of cities included.

thank you for checking those cities!! Sounds like we just have some abnormal things going on in those cities- but no errors in the code, so let's proceed as is. Honestly slightly shocking how there's only 1 MSA with the inverted income relationship.. now I want to look into morgantown WV and see what's going on there : )

ran-codes commented 2 years ago

Please see here for new version: URL: https://drexel-uhc.shinyapps.io/LE_Income_Inequalities_City_dev/

Let me know if this is what you meant? Thanks!

alinasmahl1 commented 2 years ago

Looks great! Exactly what we're hoping for. Could you please check and make sure that the labels are correct for Figure 3? It's possible the relationships are just opposite when including the full set of cities, but for example in the manuscript the Midwest has the smallest CV and SD, but in the dashboard it looks like they're the widest.

We may need to make a mock deidentified dashboard version for the article submission-- once I get feedback from the co-authors on the article I'll create a new issue about this.

ran-codes commented 2 years ago

Can you check the code I added to Analysis_edits.R . It's lines 398 to 396.

xwalk_region_name = le_by_decile %>% ungroup() %>% select(Region,Region_Name) %>% distinct()

figure3mean__RL<-cv_decile%>%
  ungroup() %>% 
  left_join(xwalk_region_name) %>% 
  filter(type=="mean")%>%
  ggplot( aes(x=decile_income, y=value, group=Region_Name)) +
  geom_line(aes(color=Region_Name), show.legend = F)+
  geom_point(aes(fill=Region_Name), size=2, color="black", pch=21)
figure3mean__RL

xwalk_region_name is the Region to Region_Name crosswalk and looks like: image

My ggplot using the >1,000,000 MSA filter and without any scale_fill_manual() or scale_colour_manual() looks like this: image

which is different than the paper figure?

alinasmahl1 commented 2 years ago

It looks like the code is correct, thanks for checking! It seems the patterns do just change when we don't restrict the MSA size. Would it be possible to add a toggle to the dashboard to examine populations >1 million vs the all MSAs? (just for figure 3)

ran-codes commented 2 years ago

mmm the weird thing is that plot above and the code above is using data ('cv_decile') which is for MSA with >1 million; meaning it should generate the same figure as the paper figure (figure3mean) but it doesn't? There may be an issue with lines 410/411 where color and labels are manually input. does that make sense?

Once we figure this out I will add a toggle button for figure 3 in the dashbaord.