library(tidyverse)
library(ggplot2)
library(dplyr)
library(readr)
library(RColorBrewer)
set110 <- read_csv("billionaires.csv")Billionaires Net Worth
Introduction
This project is about analyzing the data-set of Billionaires. The question with this data-set is to find whether billionaire’s net worth relate to their age and the year they were recorded. I also checked those according to the regions. This data-set has 2,614 observations and 22 variables.
I planned to use four variables:
- worth: This is the net worth of the billionaires in billions of USD
- age: This is the age of billionaires
- year: This is the recorded year of billionaires
- region: This is where billionaires are from
The source of the data-set is Peterson Institute for International Economicsand I got the csv file from CORGIS
Loading libraries and setting data
# Viewing some of the data
head(set110)# A tibble: 6 × 22
name rank year company.founded company.name company.relationship
<chr> <dbl> <dbl> <dbl> <chr> <chr>
1 Bill Gates 1 1996 1975 Microsoft founder
2 Bill Gates 1 2001 1975 Microsoft founder
3 Bill Gates 1 2014 1975 Microsoft founder
4 Warren Buffett 2 1996 1962 Berkshire H… founder
5 Warren Buffett 2 2001 1962 Berkshire H… founder
6 Carlos Slim Helu 2 2014 1990 Telmex founder
# ℹ 16 more variables: company.sector <chr>, company.type <chr>,
# demographics.age <dbl>, demographics.gender <chr>,
# location.citizenship <chr>, `location.country code` <chr>,
# location.gdp <dbl>, location.region <chr>, wealth.type <chr>,
# `wealth.worth in billions` <dbl>, wealth.how.category <chr>,
# `wealth.how.from emerging` <lgl>, wealth.how.industry <chr>,
# wealth.how.inherited <chr>, `wealth.how.was founder` <lgl>, …
Cleaning the data-set
# Changing the names of the three variables
set110 <- set110 |>
rename(age = demographics.age,
worth = `wealth.worth in billions`,
region = location.region)# While checking for errors, I found there were negative and zero value in "age" variable and there were also zero value in "region" variable so, I cleaned those values and stored to "cleaned" data-set.
# Then there was 2,228 observations
summary(set110$age) Min. 1st Qu. Median Mean 3rd Qu. Max.
-42.00 47.00 59.00 53.34 70.00 98.00
cleaned <- set110 |>
filter(age > 0) |>
filter(region != 0)
cleaned# A tibble: 2,228 × 22
name rank year company.founded company.name company.relationship
<chr> <dbl> <dbl> <dbl> <chr> <chr>
1 Bill Gates 1 1996 1975 Microsoft founder
2 Bill Gates 1 2001 1975 Microsoft founder
3 Bill Gates 1 2014 1975 Microsoft founder
4 Warren Buffett 2 1996 1962 Berkshire H… founder
5 Warren Buffett 2 2001 1962 Berkshire H… founder
6 Carlos Slim He… 2 2014 1990 Telmex founder
7 Paul Allen 3 2001 1975 Microsoft founder
8 Amancio Ortega 3 2014 1975 Zara founder
9 Lee Shau Kee 4 1996 1976 Henderson L… founder/chairman
10 Larry Ellison 4 2001 1977 Oracle founder
# ℹ 2,218 more rows
# ℹ 16 more variables: company.sector <chr>, company.type <chr>, age <dbl>,
# demographics.gender <chr>, location.citizenship <chr>,
# `location.country code` <chr>, location.gdp <dbl>, region <chr>,
# wealth.type <chr>, worth <dbl>, wealth.how.category <chr>,
# `wealth.how.from emerging` <lgl>, wealth.how.industry <chr>,
# wealth.how.inherited <chr>, `wealth.how.was founder` <lgl>, …
# Checking if it still has errors.
summary(cleaned$region) Length N.unique N.blank Min.nchar Max.nchar
2228 7 0 6 24
summary(cleaned$age) Min. 1st Qu. Median Mean 3rd Qu. Max.
12.00 53.00 62.00 62.57 72.00 98.00
summary(cleaned$worth) Min. 1st Qu. Median Mean 3rd Qu. Max.
1.000 1.400 2.100 3.724 3.600 76.000
Exploring the Data
# Creatinfg histogram of worth of Billionaires and adding some color
ggplot(cleaned, aes(x = worth)) +
geom_histogram(fill = "red", bins = 20) +
theme_minimal() +
labs(title = "Distribution of Billionaire's Net Worth",
x = "Net Worth (Billions)",
y = "Billionaires")# Creating scatterplot where x is age and y is net worth
ggplot(cleaned, aes(x = age, y = worth, color = region)) +
# Correcting the dots to be viewed properly using alpha
geom_point(alpha = 0.5, size = 2) +
# Using color brewer from RColowerBrewer function
scale_color_brewer(palette = "Set1") theme_minimal() +
labs(title = "Billionaire's Age and Net Worth by Regions",
x = "Age",
y = "Net Worth (Billions in USD)",
caption = "Source: Peterson Institute for International Economics ")<theme> List of 147
$ line : <ggplot2::element_line>
..@ colour : chr "black"
..@ linewidth : num 0.5
..@ linetype : num 1
..@ lineend : chr "butt"
..@ linejoin : chr "round"
..@ arrow : logi FALSE
..@ arrow.fill : chr "black"
..@ inherit.blank: logi TRUE
$ rect : <ggplot2::element_rect>
..@ fill : chr "white"
..@ colour : chr "black"
..@ linewidth : num 0.5
..@ linetype : num 1
..@ linejoin : chr "round"
..@ inherit.blank: logi TRUE
$ text : <ggplot2::element_text>
..@ family : chr ""
..@ face : chr "plain"
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : chr "black"
..@ size : num 11
..@ hjust : num 0.5
..@ vjust : num 0.5
..@ angle : num 0
..@ lineheight : num 0.9
..@ margin : <ggplot2::margin> num [1:4] 0 0 0 0
..@ debug : logi FALSE
..@ inherit.blank: logi TRUE
$ title : chr "Billionaire's Age and Net Worth by Regions"
$ point : <ggplot2::element_point>
..@ colour : chr "black"
..@ shape : num 19
..@ size : num 1.5
..@ fill : chr "white"
..@ stroke : num 0.5
..@ inherit.blank: logi TRUE
$ polygon : <ggplot2::element_polygon>
..@ fill : chr "white"
..@ colour : chr "black"
..@ linewidth : num 0.5
..@ linetype : num 1
..@ linejoin : chr "round"
..@ inherit.blank: logi TRUE
$ geom : <ggplot2::element_geom>
..@ ink : chr "black"
..@ paper : chr "white"
..@ accent : chr "#3366FF"
..@ linewidth : num 0.5
..@ borderwidth: num 0.5
..@ linetype : int 1
..@ bordertype : int 1
..@ family : chr ""
..@ fontsize : num 3.87
..@ pointsize : num 1.5
..@ pointshape : num 19
..@ colour : NULL
..@ fill : NULL
$ spacing : 'simpleUnit' num 5.5points
..- attr(*, "unit")= int 8
$ margins : <ggplot2::margin> num [1:4] 5.5 5.5 5.5 5.5
$ aspect.ratio : NULL
$ axis.title : NULL
$ axis.title.x : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : num 1
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 2.75 0 0 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.title.x.top : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : num 0
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 0 2.75 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.title.x.bottom : NULL
$ axis.title.y : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : num 1
..@ angle : num 90
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 2.75 0 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.title.y.left : NULL
$ axis.title.y.right : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : num 1
..@ angle : num -90
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 0 0 2.75
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : chr "#4D4D4DFF"
..@ size : 'rel' num 0.8
..@ hjust : NULL
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : NULL
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.x : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : num 1
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 2.2 0 0 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.x.top : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 0 4.95 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.x.bottom : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 4.95 0 0 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.y : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : num 1
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 2.2 0 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.y.left : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 4.95 0 0
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.y.right : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : NULL
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 0 0 4.95
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.text.theta : NULL
$ axis.text.r : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : num 0.5
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : <ggplot2::margin> num [1:4] 0 2.2 0 2.2
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ axis.ticks : <ggplot2::element_blank>
$ axis.ticks.x : NULL
$ axis.ticks.x.top : NULL
$ axis.ticks.x.bottom : NULL
$ axis.ticks.y : NULL
$ axis.ticks.y.left : NULL
$ axis.ticks.y.right : NULL
$ axis.ticks.theta : NULL
$ axis.ticks.r : NULL
$ axis.minor.ticks.x.top : NULL
$ axis.minor.ticks.x.bottom : NULL
$ axis.minor.ticks.y.left : NULL
$ axis.minor.ticks.y.right : NULL
$ axis.minor.ticks.theta : NULL
$ axis.minor.ticks.r : NULL
$ axis.ticks.length : 'rel' num 0.5
$ axis.ticks.length.x : NULL
$ axis.ticks.length.x.top : NULL
$ axis.ticks.length.x.bottom : NULL
$ axis.ticks.length.y : NULL
$ axis.ticks.length.y.left : NULL
$ axis.ticks.length.y.right : NULL
$ axis.ticks.length.theta : NULL
$ axis.ticks.length.r : NULL
$ axis.minor.ticks.length : 'rel' num 0.75
$ axis.minor.ticks.length.x : NULL
$ axis.minor.ticks.length.x.top : NULL
$ axis.minor.ticks.length.x.bottom: NULL
$ axis.minor.ticks.length.y : NULL
$ axis.minor.ticks.length.y.left : NULL
$ axis.minor.ticks.length.y.right : NULL
$ axis.minor.ticks.length.theta : NULL
$ axis.minor.ticks.length.r : NULL
$ axis.line : <ggplot2::element_blank>
$ axis.line.x : NULL
$ axis.line.x.top : NULL
$ axis.line.x.bottom : NULL
$ axis.line.y : NULL
$ axis.line.y.left : NULL
$ axis.line.y.right : NULL
$ axis.line.theta : NULL
$ axis.line.r : NULL
$ legend.background : <ggplot2::element_blank>
$ legend.margin : NULL
$ legend.spacing : 'rel' num 2
$ legend.spacing.x : NULL
$ legend.spacing.y : NULL
$ legend.key : <ggplot2::element_blank>
$ legend.key.size : 'simpleUnit' num 1.2lines
..- attr(*, "unit")= int 3
$ legend.key.height : NULL
$ legend.key.width : NULL
$ legend.key.spacing : NULL
$ legend.key.spacing.x : NULL
$ legend.key.spacing.y : NULL
$ legend.key.justification : NULL
$ legend.frame : NULL
$ legend.ticks : NULL
$ legend.ticks.length : 'rel' num 0.2
$ legend.axis.line : NULL
$ legend.text : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : 'rel' num 0.8
..@ hjust : NULL
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : NULL
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ legend.text.position : NULL
$ legend.title : <ggplot2::element_text>
..@ family : NULL
..@ face : NULL
..@ italic : chr NA
..@ fontweight : num NA
..@ fontwidth : num NA
..@ colour : NULL
..@ size : NULL
..@ hjust : num 0
..@ vjust : NULL
..@ angle : NULL
..@ lineheight : NULL
..@ margin : NULL
..@ debug : NULL
..@ inherit.blank: logi TRUE
$ legend.title.position : NULL
$ legend.position : chr "right"
$ legend.position.inside : NULL
$ legend.direction : NULL
$ legend.byrow : NULL
$ legend.justification : chr "center"
$ legend.justification.top : NULL
$ legend.justification.bottom : NULL
$ legend.justification.left : NULL
$ legend.justification.right : NULL
$ legend.justification.inside : NULL
[list output truncated]
@ complete: logi TRUE
@ validate: logi TRUE
Regression Analysis
# Performing linear regression and storing in model
model <- lm(worth ~ age + year, data = cleaned)
# Used summary to find required values
summary(model)
Call:
lm(formula = worth ~ age + year, data = cleaned)
Residuals:
Min 1Q Median 3Q Max
-3.933 -2.254 -1.494 -0.072 72.219
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -96.939939 33.873127 -2.862 0.004251 **
age 0.032921 0.008728 3.772 0.000166 ***
year 0.049062 0.016879 2.907 0.003689 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.38 on 2225 degrees of freedom
Multiple R-squared: 0.01117, Adjusted R-squared: 0.01028
F-statistic: 12.57 on 2 and 2225 DF, p-value: 3.726e-06
# Loaded "ggfortify" library for autoplot
library(ggfortify)
# Shows four plot that check the assumptions
autoplot(model)Equation
\[ \widehat{worth} = b_0 + b_1(age) + b_2(year)\]
\[\widehat{worth} = -96.93993937 + 0.03292116(age) + 0.04906227(year)\]
Conclusion
The analysis showed whether a billionaire’s net worth is related to their age and the year recorded, where there is a statistically significant but a weak connection. The net worth is heavily right skewed, scatter-plot shows unusual trends. From the multiple linear regression model, one extra year of age results in a net worth of $33 million while an extra year after that means an increase of $49 million. Nevertheless, age and year account for 1.1 percent of the variability in net worth, making them bad predictors of wealth for billionaires.
Technical Challenges and Future Studies
While performing the analysis, I faced lots of consequences. First being poor quality of the data where I had to remove zero values and rename some variables. This reduced the dataset to 2228 observations. Second, the net worth is strongly right skewed and these large values caused the model hard to fit in. Lastly, the regression assumptions did not met. Normal Q-Q plot curved sharply upwards, and the Scale-Location plot showed that spread of the errors grew as values increased.
My future studies would be changing the variables, like industry, source of wealth etc. and trying new analysis or going deep into the variables and figuring out how I can find more patterns.