Posts for Tag: graph

How do Americans Spend Money? US Household Spending Breakdown by Education Level

Posted In: Money
Facebooktwittergoogle_plusredditpinterestlinkedinmail
How much do US households spend and how does it change with education level?

This visualization is one of a series of visualizations that present US household spending data from the US Bureau of Labor Statistics. This one looks at the education level of the primary resident.

This visualization focuses on the education level of the primary resident. This is defined in the BLS documentation as the person who is first mentioned when the survey respondent is asked who in the household rents or owns the home.

I obtained data from the US Bureau of Labor Statistics (BLS), based upon a survey of consumer households and their spending habits. This data breaks down spending and income into many categories that are aggregated and plotted in a Sankey graph.

One of the key factors in financial health of an individual or household is making sure that household spending is equal to or below household income. If your spending is higher than income, you will be drawing down your savings (if you have any) or borrowing money. If your spending is lower than your income, you will presumably be saving money which can provide flexibility in the future, fund your retirement (maybe even early) and generally give you peace of mind.

Instructions:

  • Hover (or on mobile click) on a link to get more information on the definition of a particular spending or income category.
  • Use the dropdown menu to look at averages for different groups of households based on the education level of the primary resident. This data breaks households into the following groups:
    • All
    • Less than HS graduate
    • High school graduate
    • HS grad + some college
    • Associate’s degree
    • Bachelor’s degree
    • Master’s, professional, doctoral degree

    The composition of households and income change as the education level of the primary resident changes, which in turn affects spending totals and individual categories.

As stated before, one of the keys to financial security is spending less than your income. We can see that on average, income tends to increase with education level. Those with the highest incomes and greatest spending have advanced degrees, but they also save the most money.

The group with the lowest education level (not finishing high school) have the lowest income and on average needs to borrow or draw down on savings to live their lifestyle.

How does your overall spending compare with those that have the same education level as you? How about spending in individual categories like housing, vehicles, food, clothing, etc…?

Probably one of the best things you can do from a financial perspective is to go through your spending and understand where your money is going. These sankey diagrams are one way to do it and see it visually, but of course, you can also make a table or pie chart (Honestly, whatever gets you to look at your income and expenses is a good thing).

The main thing is to understand where your money is going. Once you’ve done this you can be more conscious of what you are spending your money on, and then decide if you are spending too much (or too little) in certain categories. Having context of what other people spend money on is helpful as well, and why it is useful to compare to these averages, even though the income level, regional cost of living, and household composition won’t look exactly the same as your household.

**Click Here to view other financial-related tools and data visualizations from engaging-data**

Here is more information about the Consumer Expenditure Surveys from the BLS website:

The Consumer Expenditure Surveys (CE) collect information from the US households and families on their spending habits (expenditures), income, and household characteristics. The strength of the surveys is that it allows data users to relate the expenditures and income of consumers to the characteristics of those consumers. The surveys consist of two components, a quarterly Interview Survey and a weekly Diary Survey, each with its own questionnaire and sample.

Data and Tools:
Data on consumer spending was obtained from the BLS Consumer Expenditure Surveys, and aggregation and calculations were done using javascript and code modified from the Sankeymatic plotting website. I aggregated many of the survey output categories so as to make the graph legible, otherwise there’d be 4x as many spending categories and all very small and difficult to read.

household spending

What are the highest mountains on Earth? Measuring from sea level vs center of earth

Posted In: Geography
Facebooktwittergoogle_plusredditpinterestlinkedinmail

The Highest Mountains On Earth Depend On How You Measure “High”

Mount Everest is famous for being the highest mountain on Earth. The peak is an incredible 8,848 meters (29,029 ft) above sea level. But that is only one way to measure the height of a mountain. Chimborazo, a mountain in Ecuador, holds the distinction for the mountain whose peak is the furthest from the center of the Earth. How is that possible? This is because the Earth is not a perfect sphere. Rather, due to the spinning of the Earth around it’s axis, the centrifugal force causes the equator to bulge out slightly. This flattened shape is called an oblate spheroid and makes the radius of the earth at the equator about 22 km (about 0.3%) larger than the radius to the poles. Mountains close to the equator will “start” further away from the center of the earth, than those at higher latitudes.

This graph plots over 800 of the highest mountains on Earth with their peak height above sea level on the x-axis and their peak distance from the center of the earth on the y-axis. Each point represents one mountain. The colors of the plots correspond to the latitude of the mountain. These mountains range from 3000 meters in height to 9000 meters in height. You can hover over a data point (or click on mobile) to get more information about the mountain. You can also switch from metric to imperial units with the button on the graph.

For a given mountain range at a certain latitude, you can see that as the mountain heights above sea level increases, so does their distance from the center of the Earth. Mountains in the southern hemisphere are colored in blue, those around the equator are green and yellow, and those in the northern hemisphere are red and orange. The mountains with the highest peaks above sea level are shown on the right side of the graph in red and orange (mostly in the Himalaya), with Mt Everest as the right most point on the graph (nearly 9000 meters tall).

Mountains with peaks the greatest distance from the center of the earth are found near the equator in light green/yellow and are found at the top of the graph. You’ll notice that a number of these mountains are higher than Mt Everest when looking at the distance from the center of the earth.

The Himalayas are the “highest” mountains on earth if you are measuring height from sea level, while the Andes are the “highest” if you measure from the center of the earth.

 

Calculating Distance from Earth’s Center to Mountain Peak

The distance from the center of the Earth is calculated from the following formula:
$$D_{mountain} = H_{mountain} + R_{lat}$$
where $D_{mountain}$ is the distance from center of earth to the top of the mountain, $H_{mountain}$ is the mountain height above sea-level and $R_{lat}$ is the radius of earth at the mountain’s latitude. The height is data that was downloaded from a list of mountain heights.

and the radius of the earth for a given latitude is calculated using the formula:
$$R_{lat}=\sqrt{a^2cos(lat)^2+b^2sin(lat)^2\over acos(lat)^2+bsin(lat)^2)}$$
where $a$ and $b$ are the equatorial and polar radii (6378.137 km and 6356.752 km respectively).
 

Earth Radius Calculator

Here is a calculator for determining the radius of Earth at a given latitude:

You can use this to calculate the distance from the center of the earth to sea level at your latitude.

 

Data and Tools:
Data on the heights of over 800 mountain peaks over 3000 meters in height was downloaded from Wikipedia. There ended up being alot of google searching and data cleaning to get it into suitable format for plotting. The calculations were made with javascript and plotted using plotly, the open source javascript graphing library.

Mountain Height Graph

Mercury is the closest planet to Earth (on average)

Posted In: Science
Facebooktwittergoogle_plusredditpinterestlinkedinmail

We all learned the order of planets in school. In my case using the mnemonic, My Very Excellent Mother Just Served Us Nine Pizzas (MVEMJSUNP) for Mercury, Venus, Earth, Mars Jupiter Saturn, Uranus, Neptune, and Pluto. Since Pluto has been demoted to a dwarf planet, you could change the Nine Pizzas to Noodles or something else.

And in terms of distances, Venus’s orbit (0.72 AU, or Astronomical Units (i.e. 1 AU is the distance from the Earth to the Sun) is closer to Earth’s orbit (1 AU by definition) than Mercury’s (varies between 0.31 and 0.47 AU because of it’s more elliptical orbit) or Mars’ (1.5 AU).

However, I saw an article, stating that Mercury might in fact be the closest planet to Earth (on average) so I thought I’d whip up a visualization that shows which planet is closest as a function of the planetary orbits around the sun.

Because of where the planets are on these orbital paths, and specifically the time it takes Mercury to orbit the sun, Mercury is the planet that is closest to Earth more often and has an average distance to Earth that is lower than the other 2 inner planets. Mars is occasionally the closest as well, but on average much further than Mercury or Venus. Also interesting is that Mercury is, on average, about 1 AU away from Earth, which is the same as the distance to the Sun.

This simulation shows how the planet positions vary each day over a 30 year period and the regularity with which the distance between Earth and the other varies over time. Mercury has the shortest period while Mars has the longest. You can change the speed of the simulation to speed up or slow down the orbits of the planets.

Data and Tools:
I thought about simulating the planets but there are plenty of tools out there that generate this orbital data so instead just downloaded ephemeris data (data related to positions of astronomical bodies) from NASA website.. I processed the data using javascript and drew the picture using HTML canvas tools and made the distance vs time plot with the Plotly open source plotting javascript library.

Mercury is closest planet to Earth

Estimating pi (π) using Monte Carlo Simulation

Posted In: Math
Facebooktwittergoogle_plusredditpinterestlinkedinmail

This interactive simulation estimates the value of the fundamental constant, pi (π), by drawing lots of random points to estimate the relative areas of a square and an inscribed circle.

Pi, (π), is used in a number of math equations related to circles, including calculating the area, circumference, etc. and is widely used in geometry, trigonometry and physics.

This app estimates the value of pi by comparing the area of a square and an inscribed circle. The areas are calculated by randomly placing dots into the square and then counting how many of them are also inside the circle. If you do this enough times, you will get a rough ratio of the relative areas of the two shapes. These points are plotted on the graph (red if the fall inside the circle and blue if the fall outside).

Also shown on the graph is the value of our estimate of pi as the simulation progresses, from a few points to many thousands, to millions of points. We can see that when we have only a few points, the value may not be very accurate but as the number of points increases the value of our estimate gets closer to the true value. Running the simulation will add and plot 1 million points. After the first 100 points are added, the rate at which points are added increases. You’ll notice this as the speed at which dots fills up the square increases and because the plot is shown with a logarithmic x-axis.

Here is the math:
Length of side of square: $2 \times r$
radius of circle: $r$
Area of square: $A_{square} = 4r^2$
Area of circle: $A_{circle} = \pi r^2$

The ratio of areas is $A_{circle}/A_{square} = \pi r^2 / 4r^2 = \pi / 4$
Solving for pi: $\pi = 4 \times A_{circle}/A_{square} \approx 4 \times N_{dots_{circle}}/N_{dots_{square}}$
So pi is estimated as 4 times the ratio of dots in the circle vs square

Tools:
This was programmed in javascript, canvas and plotted using the open source plotly javascript plotting library.
estimating pi using monte carlo

Rubik’s Cube World Records for 3×3 Puzzles (Regular, feet, blindfolded, one-handed)

Posted In: Fun
Facebooktwittergoogle_plusredditpinterestlinkedinmail

I recently taught my daughter how to solve the rubik’s cube using “the beginner method”. She’s getting decently fast, but when we watched some youtube videos about really fast speed cubers, we were blown away by how fast people can solve the cube. The world record time is under 4 seconds! I thought it’d be fun to document the progression of world records since the cube was introduced in 1980.

What was interesting in looking through the records are the strange events that people compete in and post amazing times in. Blindfolded! With Feet! One-handed! Feet or one-handed is at least in the realm of possibility, though it would slow down my already slow solves, but blindfolded is next-level stuff.

Hover over the different data series for the events to see the record-holder’s name, country, solve time and competition for each world record. You can also toggle the y-axis scale from linear to log scale in order to distinguish between the latest world records as they tend to converge and have very small changes.

Not sure if it’s motivating or discouraging to see these ridiculously fast solve times. Knowing that we’ll never be able to beat people who solve the cube blindfolded is a bit humbling.

Data and Tools:
Data was downloaded from cubecomps.com, a speed cubing website and the data was plotted using the open-sourced Plot.ly javascript engine.

rubik's cube world record times

How do Americans Spend Money? US Household Spending Breakdown by Income Group

Posted In: Money
Facebooktwittergoogle_plusredditpinterestlinkedinmail
How much do US households spend?

This visualization is one of a series of visualizations that present US household spending data from the US Bureau of Labor Statistics. This one looks at the income of the household.

One of the key factors in financial health of an individual or household is making sure that household spending is equal to or below household income. If your spending is higher than income, you will be drawing down your savings (if you have any) or borrowing money. If your spending is lower than your income, you will presumably be saving money which can provide flexibility in the future, fund your retirement (maybe even early) and generally give you peace of mind.

I obtained data from the US Bureau of Labor Statistics (BLS), based upon a survey of consumer households and their spending habits. This data breaks down spending and income into many categories that are aggregated and plotted in a Sankey graph.

Instructions:

  • Hover (or on mobile click) on a link to get more information on the definition of a particular spending or income category.
  • Use the dropdown menu to look at averages for different groups of households based on income. This data breaks households into quintiles (groups of 20%) by income. The lowest quintile group is the group of 20% of households with the lowest income (and spend on average ~$25,500/yr).

As stated before, one of the keys to financial security is spending less than your income. We can see that on average, those in the lowest quintiles may be borrowing or drawing down on savings to live their lifestyle, while those in the highest quintiles are saving money and contributing to wealth. This fairly high level of borrowing/drawing on savings from the lowest quintile households may be deceptive because it includes seniors who are drawing down savings that were built up specifically for this purpose, and college students who are borrowing to go to school. These groups generally don’t have significant incomes.

How does your overall spending compare with those in your income group? How about spending in individual categories like housing, vehicles, food, clothing, etc…?

Probably one of the best things you can do from a financial perspective is to go through your spending and understand where your money is going. These sankey diagrams are one way to do it and see it visually, but of course, you can just make a table or pie chart or whatever.

The main thing is to understand where your money is going. Once you’ve done this you can be more conscious of what you are spending your money on, and then decide if you are spending too much (or too little) in certain categories. Having context of what other people spend money on is helpful as well, and why it is useful to compare to these averages, even though the income level, regional cost of living, and household composition won’t look exactly the same as your household.

**Click Here to view other financial-related tools and data visualizations from engaging-data**

Here is more information about the Consumer Expenditure Surveys from the BLS website:

The Consumer Expenditure Surveys (CE) collect information from the US households and families on their spending habits (expenditures), income, and household characteristics. The strength of the surveys is that it allows data users to relate the expenditures and income of consumers to the characteristics of those consumers. The surveys consist of two components, a quarterly Interview Survey and a weekly Diary Survey, each with its own questionnaire and sample.

Data and Tools:
Data on consumer spending was obtained from the BLS Consumer Expenditure Surveys, and aggregation and calculations were done using javascript and code modified from the Sankeymatic plotting website. I aggregated many of the survey output categories so as to make the graph legible, otherwise there’d be 4x as many spending categories and all very small and difficult to read.

household spending