Data Visualization on Cost of Living

Posted on Feb 18, 2018
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Introduction

As someone who has lived in three different cities over the past five years, I know firsthand that a city's cost of living can influence the lifestyle choices we make, and data could also support my claim.

From the city and dwelling's in which we live, to the goods and services we consume, the cost of living estimator formulates a useful measure to compare expenses across locations.

Factors that influence this measure are based on qualities of our personal lives, for example:

  • Do you have a spouse and/or kids?
  • Do you live in the suburbs or downtown?
  • If you use public transportation or do you drive?
  • Do you eat out? If so, how many times?

In an effort to help people compare locations, I sought to scrape the web for real-time cost of living measures, and develop a cost of living estimator.

Data Collection

I set-out to scrape web-pages that would help me compute an overall cost of living estimate (food, clothes, childcare, etc.), but half-way through I found a website called Numbeo. Numbeo collects and shares the maximum, minimum, and average value of various cost estimates provided by users. I used Scrapy, a web scraping framework, to gather cost of living estimates for 55 U.S. Cities. The data set contains 28 monthly cost estimates, including:

  • Daily Food Prices (Grains, Vegetables, Fruits, Protein, Grains, Dairy)
  • Meal Cost (3-course meal, inexpensive meal, fast-food meal)
  • Gas Prices
  • Services (Utilities, Monthly Transportation, Internet, Childcare, Fitness)
  • Apartment Rental Prices (1 or 3 Bedroom)

Data Visualization on Cost of Living

Data Munging

Once the data was collected, I worked in Python to clean up the resulting data. This included extracting the count of users who comprise each city's cost statistic and appending it to the data set.

Data Visualization on Cost of Living

Furthermore, based on Hugh Kelly's 24-Hour Cities, I appended city profile to the data set, resulting in another dimension for benchmarking purposes.  This process included tagging each city in my dataset as a 24-hour city, a 18-hour city, a 2nd tier market, or a small market.

Data Analysis

Next up, data visualization and analysis. This included exploring the distribution and dispersion of the individual cost measures and aggregating these cost measures across the markets in the study.

I then proceeded to formulate and test the null hypothesis, which questioned if regions or city profiles significantly impact the cost of living estimate.

Data Visualization on Cost of Living

 

I wanted to expand on this analysis, and test whether a market is unique in nature across all of cost of living estimators and markets. So, I decided to use Fisher's Method of combining the P-values. Fisher's method is typically applied to a collection of independent test statistics, usually from separate studies having the same null hypothesis. In order to facilitate this analysis, I built a P-value matrix with respect to each market and cost of living estimator in my analysis.

Fisher’s method takes the log of the P-value and multiplies by -2. Under the null hypothesis, we have:

-2 \sum_{i=1}^{k} \log(p_i) \sim \chi_{2k}^{2}

The negative log of uniform random variables follows an exponential distribution. When scaled by 2 these follow a chi-squared distribution with 2 degrees of freedom, and a sum of chi-squared distributions is also chi-squared with the degrees of freedom summed.

Applying Fisher's Method results in an overall test statistic and P-value for all markets. If the P-values are lower than expected under the null hypothesis, then the combined value from Fisher’s method will be in the upper tail.

Below is a result of my analysis:

Markets such as New York, Saint Louis, and San Francisco have estimations that make them unique. Please note, since I did not have the underlying data, I approximated the standard error for each P-value using the formula: (Max-Min/4)/Square Root(Response Count).

Cost of Living Estimator

Built in R Shiny, the Cost of Living Estimator rolls up the 28 cost of living measures and benchmarks various cities against one-another.

How does it work?

Input qualities about your life, including your monthly take-home pay, and watch the application calculate a monthly cost estimate and approximate your disposable income for 55 U.S. cities. Assumptions are incorporated in this calculation; for example, if you are married with more than one kid, we assume you are in a 3-bedroom apartment.

Next Steps

I plan to establish a data pipeline that updates the cost of living measures routinely. Thank you for browsing my project and don't hesitate to reach out if you have any additional questions or feedback on my approach and techniques used. If interested, access my code repository on GitHub.

About Author

Raj Tiwari

Raj has 8 years of experience in solving challenging problems and accelerating business growth through data-driven analyses. Raj has a M.S. in Business Analytics from Fordham University in New York City and a B.S. in Economics and Applied...
View all posts by Raj Tiwari >

Related Articles

Leave a Comment

No comments found.

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