Diabetes, Obesity, and Income

Posted on Nov 18, 2015

Contributed by William Aiken. William took NYC Data Science Academy 12 week full time Data Science Bootcamp program between Sept 23 to Dec 18, 2015. The post was based on his second class project(due at 4th week of the program).

This was my first data science project associated with the bootcamp.  The goal of this project was a visualization and explorations of New York state diabetic incidence data.  I wanted to look at data sets where there existed previously established relationships.  I chose a public health issue of diabetic rates and obesity, it has been shown that there is a strong link between these two issues.  I thought it would be of interest to see how this relationship played out in New York state.  The data used were part of the 1,250 freely available data sets on the ny.gov website, an amazing resource for public health issues.  Four different sets were utilized: an income data set; a diabetic rate set; a diabetic mortality rate and an obesity rate data set(all from 2009).  All of these data sets provided granularity at the  county level.  The inclusion of the last three data sets are very straight forward.  Income data was included in this analysis for two reasons, first there is a long established relationship between income and diabetic rates.  Secondly, New York is the only state where the poorest county(Bronx) is directly adjacent to the most affluent county(Manhattan/New York County).  I was curious to see what relationships existed alongside this economic disparity.  New York state contains fifty-two counties so I wanted to find a way to represent this data that made comparisons between counties easy and also retained spacial relations.   Choropleth maps were ideal for this task.  These maps use color intensity to represent aggregated data within a geographic region, either intensive or extensive.  Luckily for me, the R programming language had several libraries to aid in this mapping, choroplethR had the shallowest learning curve.  Rather than just bury the reader in plots, I will present only the most interesting plots in the post.  But here is a link to a Shiny application that I created that will allow you to explore with all the data.  Shiny App

Before my data could be mapped with choroplethR library it required some manipulation.  Thankfully the data was complete, if anything there was more data than I required.  Several of the data sets contained information years beyond 2009, my year of interest.  Some data sets included aggregations of regions that required exclusion.  Lastly all of the data sets contained formating that required adjusting so they joined with the FIPs dataset required by choroplethR.  

Here is the code for the for my loading and data munging.

library(choroplethr)
library(choroplethrMaps)
library(dplyr)
library(ggplot2)
data("county.regions")

Income <- read.csv("AverageIncome.csv",stringsAsFactors = FALSE)
Mortality <- read.csv("Mortality2009-2011.csv",stringsAsFactors = FALSE)
Obese <- read.csv("Obese08-09.csv",stringsAsFactors = FALSE)
Diagnosed <- read.csv("Diagnosed.csv",stringsAsFactors = FALSE)

Diagnosed <- rename(Diagnosed, County = County.Name)
Income <- rename(Income, County = Place.of.Residence)
Obese <- rename(Obese, County = County.Name)
Mortality <- rename(Mortality, County = County.Name)
Income$County <- as.character(Income$County)


Income <-mutate(Income, County=ifelse(County=="New York City - Bronx", "Bronx", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Kings", "Kings", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Manhattan", "New York", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Queens", "Queens", County))
Income <-mutate(Income, County=ifelse(County=="New York City - Richmond", "Richmond", County))


Income09 <- filter(Income, Tax.Year %in% 2009)
Income09 <- mutate(Income09, County = ifelse(County == "new york city", "new york", County))


Obese$County <- tolower(Obese$County)
Income$County <- tolower(Income$County)
Mortality$County <- tolower(Mortality$County)
Diagnosed$County <- tolower(Diagnosed$County)


DiaDiagnosed <- filter(Diagnosed, Diagnosed$Health.Topic %in% "Cirrhosis/Diabetes Indicators")


DiaDiagnosed <- rename(DiaDiagnosed, value = Percent.Rate)
Mortality <- rename(Mortality, value = Percentage.Rate)
Income09 <- rename(Income09, value = Average.NY.AGI.of.All.Returns)
Obese <- rename(Obese, value = Percentage.Rate)


Test <- filter(county.region, state.name %in% "new york")


Test2 <- left_join(Test, Obese, by = c("county.name" = "County"))
Test3 <- left_join(Test, Income09, by = c("county.name" = "County"))
Test4 <- left_join(Test, DiaDiagnosed, by = c("county.name" = "County"))
Test5 <- left_join(Test, Mortality, by = c("county.name" = "County"))

 

Here is the choropleth map of diabetic rates for all the counties in New York state in 2009.  The values represent all the percent of the population that has been diagnosed by a doctor as being diabetic.

 

New York Diabetic Rates

Here is a choropleth map of all the average incomes within the five New York City counties.  The disparity between Manhattan and the other four counties is striking.NYC Average Income

 

 

After the data sets had been joined to the FIPs county data set they could be visualized with choroplethR.  The code for the plots is listed here.

county_choropleth(Test2,
                 title      = "2009 New York State Obesity Rates",
                 legend     = "% Population Obese",
                 num_colors = 1,
                 state_zoom = c("new york"))
                 
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test2,
                   title       = "2009 New York City Obesity Rates",
                   legend      = "% Population Obese",
                   num_colors  = 1,
                   county_zoom = new_york_city)

county_choropleth(Test3,
                   title      = "2009 Average Incomes by County",
                   legend     = "Average Income in Thousands of $",
                   num_colors = 9,
                   state_zoom = c("new york")) + scale_fill_brewer(palette=2)
                   
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test3,
                   title       = "2009 Average Income",
                   legend      = "Income in Thousands",
                   num_colors  = 9,
                   county_zoom = new_york_city)+scale_fill_brewer(palette=2)

county_choropleth(Test4,
                   title      = "Diabetic Rates per County",
                   legend     = "Percent of population with Diabetes",
                   num_colors = 9,
                   state_zoom = c("new york")) + scale_fill_brewer(palette=3)
                   
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test4,
                   title       = "Diabetic Rates per County",
                   legend      = "Percent of population with Diabetes",
                   num_colors  = 9,
                   county_zoom = new_york_city)+scale_fill_brewer(palette=3)

county_choropleth(Test5,
                   title      = "Diabetic Deaths per County 2009-2011",
                   legend     = "Percent of Deaths Caused by Diabetes",
                   num_colors = 9,
                   state_zoom = c("new york")) + scale_fill_brewer(palette=4)
                   
new_york_city = c(36005, 36047, 36061, 36081, 36085)
county_choropleth(Test4,
                   title       = "Percent of Diabetic Deaths per County",
                   legend      = "Percent of Deaths Caused by Diabetes",
                   num_colors  = 9,
                   county_zoom = new_york_city)+scale_fill_brewer(palette=4)

 

Here is a scatterplot exploring the relationship between the diabetic rates for each county and their corresponding obesity rate.  It's worth noting that this data is inherently normalized  due of it's ratio nature (incidence per 100,000 residents).Income vs Diabetic Rate

 

The data was also plotted in scatterplots to better visualize some of the non-spacial relationships within the data sets.  The code for the scatterplots is listed below.

qplot(Test3$value, Test4$value, xlab = "Income in Thousands", ylab = "Percent Diabetic",
 main = "Average Income vs Diabetic Rate in New York Counties") + (geom_smooth())

qplot(Test3$value, Test5$value, xlab = "Income in Thousands", ylab = "Percent of Deaths attributed to Diabetes",
 main = "Average Income vs Diabetic Mortality Rate in New York Counties") + (geom_smooth())

qplot(Test3$value, Test2$value, xlab = "Income in Thousands", ylab = "Percent Obese",main = "Average Income vs Obese Rate in New York Counties") +
(geom_smooth())

qplot(Test4$value, Test2$value, xlab = "Percent Diabetic", ylab = "Percent Obese",main = "Percent Diabetic vs Percent Obese") +
(geom_smooth())

 

Conclusion:

The data substantiated the already established relationships between income, obesity and diabetes.  Counties with the highest average incomes had the lowest incidence of diabetes.  The link between obesity and diabetes was also shown.  Interestingly, counties with high incomes and high obesity rates had low rates of diabetes.  The link between income and diabetes may be as strong as the relationship between diabetes and obesity.  I haven't included my Shiny app code for the sake of space put it can be found on my Github here.My Github

 

About Author

William Aiken

Nate Aiken graduated from City College in 2014 with a BS in Biology with a focus in Neuroscience. His experience studying vision and hearing in labs at City and Rockefeller University led him to the bootcamp. He enjoys...
View all posts by William Aiken >

Leave a Comment

Google September 2, 2020
Google The time to read or pay a visit to the material or web pages we have linked to beneath.
Lorenzo Sànchez Mèndez March 14, 2017
Hi William Aiken, I`m Lorenzo Sànchez from Mexico. I`ve read your post and your application is very interesting. I will start to develop a data science application for diabetes mellitus E11 and E14, and I would like that you may explain me more about the process you followed, since the beginning to the end. Did you write a paper? if so, could you send it me ? This, in order to cite you thanks for your attention, I will be waiting for the answer My email: [email protected] Lorenzo Sànchez Mèndez
boucles d'oreilles Van Cleef & Arpels replique September 20, 2016
cartierbraceletlove muy buenas, el 19-07-2015 me dieron un golpe por detrás, actual mente sigo de baja y con dolor en cervicales ( no puedo mover muy bien el cuello) soy autónomo y me gustaría saber si hubiera alguna manera de saber si los autónomos como trabajador por tu cuenta indemnizan mas cantidad o no, ya que estoy en una situación un poco extrema y me tengo que poner a trabajar ya mismo para poder llegar a fin de mes y puedo hasta perder mi trabajo, estaría muy interesado en que me pudieran orientar,muchas gracias de antemano. boucles d'oreilles Van Cleef & Arpels replique http://www.bijouxclassique.net/replica-van-cleef-earrings-c3_90.html
bijoux van cleef and arpels 10 motif prix August 18, 2016
http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-white-mother-of-pearl-vcara42100-p217.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-carnelian-vcard40800-p332.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-diamond-vcara40900-p333.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-diamond-vcarf48900-p334.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-ring-onyx-vcara41000-p335.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-earclips-carnelian-vcard40400-p306.html http://www.vancleefalhambra.com/cheap-sweet-alhambra-earstuds-heart-carnelian-vcarn6bp00-p305.html http://www.vancleefalhambra.com/cheap-sweet-alhambra-earstuds-clover-carnelian-vcarn6bo00-p304.html http://www.vancleefalhambra.com/cheap-sweet-alhambra-earstuds-butterfly-white-mother-of-pearl-vcarn5jm00-p303.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-yellow-gold-vcara42800-p220.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-vcara43100-p221.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-earclips-turquoise-vcarb84100-p309.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-earclips-turquoise-vcara44400-p308.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-vcaro3qj00-p230.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-malachite-vcarl88100-p229.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-white-mother-of-pearl-vcarf48800-p228.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-vcarf48500-p227.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-necklace-10-motifs-vcard40600-p226.html http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-carnelian-vcard39800-p225.html bijoux van cleef and arpels 10 motif prix http://www.meilleurbijoux.ru/
van cleef & arpels necklace August 3, 2016
cartierbraceletlove Por lo que comentas si que es compatible. Tienes que tener en cuenta que también entra en juego la calidad de fabricación, si el teléfono es de marca dudosa, es muy común los problemas que comentas. Un saludo. van cleef & arpels necklace http://www.vancleefalhambra.com/cheap-vintage-alhambra-long-necklace-yellow-gold-vcara43200-p222.html
แหล่งขายที่นอนราคาถูก April 3, 2016
I don't even know how I finished up right here, however I believed this put up used to be great. I do not understand who you are however certainly you are going to a well-known blogger in case you aren't already. Cheers!
occasion auto March 17, 2016
I am in fact delighted to glance at this webpage posts which contains plenty of helpful facts, thanks for providing such statistics.
pinoy movies March 12, 2016
I really like what you guys tend to be up too. This type of clever work and reporting! Keep up the terrific works guys I've you guys to blogroll.
Hadlow Village Hall is set in the beautiful Kent countryside, and offers a great venue for your Club, Activity or Event. February 15, 2016
I take pleasure in, cause I found exactly what I used to be looking for. You've ended my 4 day lengthy hunt! God Bless you man. Have a nice day. Bye
anavar December 27, 2015
The 2 sites are undoubtedly listed over the complete of this amazing article. If that being said then you will may have Gram-Negative Folliculitis. Overcome to build started at this time.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI