Skip to content

Instantly share code, notes, and snippets.

@cavedave
Last active November 22, 2020 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cavedave/ffd5c0f745c153c371c23bff0aabf01f to your computer and use it in GitHub Desktop.
Save cavedave/ffd5c0f745c153c371c23bff0aabf01f to your computer and use it in GitHub Desktop.
When would Simon–Ehrlich wager be won by whom?
library(readxl)
library(ggplot2)
library(dplyr)
library(tidyr)
copp <- read_excel("ds140-coppe.xlsx",skip = 4)
n<-dim(copp)[1]
copp<-copp[1:(n-3),]
copp<- rename(copp, copper = 'Unit value ($/t)')
copp<-select(copp, -c('Primary production', 'Secondary production','New scrap','Refinery scrap', 'Imports','Exports','Stocks','Apparent consumption','Unit value (98$/t)','World production','Consumption'))
chrom <- read_excel("ds140-chrom.xlsx",skip = 4)
n<-dim(chrom)[1]
chrom<-chrom[1:(n-4),]
chrom<-select(chrom, -c('Primary production', 'Secondary production', 'Imports','Exports','Industry stocks','Government stocks', 'Reported chromite ore consumption','Reported chromium ferroalloy and metal consumption','Apparent consumption','Unit value (98$/t)','World production'))
chrom<- rename(chrom, chromium = 'Unit value ($/t)')
nick <- read_excel("ds140-nicke.xlsx",skip = 4)
n<-dim(nick)[1]
nick<-nick[1:(n-3),]
nick<-select(nick, -c('Primary production', 'Secondary production', 'Imports','Exports','Stocks','Apparent consumption','Unit value (98$/t)','World production'))
nick<- rename(nick, nickel = "Unit value ($/t)")
ti <- read_excel("ds140-tin.xlsx",skip = 4)
n<-dim(ti)[1]
ti<-ti[1:(n-3),]
ti<-select(ti, -c('Primary production','Government shipments','Government stocks','Industry stocks', 'Secondary production', 'Imports','Exports','Apparent consumption','Unit value (98$/t)','World production'))
ti<- rename(ti, tin = "Unit value ($/t)")
tung <- read_excel("ds140-tungs.xlsx",skip = 4)
n<-dim(tung)[1]
tung<-tung[1:(n-3),]
tung<-select(tung, -c('Primary production','Government shipments','Stocks', 'Secondary production', 'Imports','Exports','Apparent consumption','Unit value (98$/t)','World production','Reported consumption'))
tung<- rename(tung, tungsten = "Unit value ($/t)")
#tung ti nick chrom copper
df <- left_join(tung, ti,
by = c("Year" = "Year"))
df <- left_join(df, nick,
by = c("Year" = "Year"))
df <- left_join(df, chrom,
by = c("Year" = "Year"))
df <- left_join(df, copp,
by = c("Year" = "Year"))
df <- df %>% mutate(sumr= tungsten + tin + nickel + chromium + copper)
#work out price difference in 10 years
df <- df %>% mutate(ten= (lead(sumr, k = 10 )-sumr ))
df <- df %>% mutate(simon= df$ten>0 )
data_long <- gather(df, metal, price, tungsten:tin:nickel:chromium:copper, factor_key=TRUE)
data_long$Year=as.numeric(data_long$Year)
#clean up later values we cant have answer for
data_long<-data_long %>% filter(!is.na(ten))
data_long<- rename(data_long, Metal = metal)
p<-ggplot(data_long, aes(x=Year, y=price, fill=Metal)) +
geom_area(aes(fill=Metal))+
scale_x_discrete(name="Years", limits=c(1900,1925,1950,1975,2000))+
labs(title = "Simon–Ehrlich Wager",
subtitle = "Bet that Price of 5 Metals would be lower in 10 years",
caption = "by: @iamreddave")+
xlab("Year") + ylab("Price $")
p<-p+ geom_linerange(data=data_long,aes(x=Year,ymin=-5000, ymax=-100,color=simon),size=4,alpha=0.8)+
scale_color_manual("Winner", values = c("green", "red"), labels = c("Lower", "Higher"))
#colors
#606564 tungsten
#tin #c84642
#copper da8a67
#0f9851 nickel
#chromium #c6c8c9
p<-p+ scale_fill_manual(values=c("#606564", "#c84642", "#0f9851","#c6c8c9","#da8a67"))
p<-p+theme_bw()+theme(plot.title = element_text(hjust = 0.5))
p
The Simon–Ehrlich wager was a 1980 scientific wager between business professor Julian L. Simon and biologist Paul Ehrlich, betting on a mutually agreed-upon measure of resource scarcity over the decade leading up to 1990
https://en.wikipedia.org/wiki/Simon%E2%80%93Ehrlich_wager
Roughly it was a bet where Simon thought things would get better as people invented and organised. Eldrich thought we would run out of stuff and overpopulation would result in starvation of hundreds of millions.
Simon won the bet as these metals were cheaper ten years later. But I wondered how ofter Simon would be rigth if the bet happened at different times.
Ten years later metals would be cheaper 55% of the time in this dataset.
Data from https://www.usgs.gov/centers/nmic/historical-statistics-mineral-and-material-commodities-united-states
@cavedave
Copy link
Author

work2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment