Julian Simon liked to proclaim that

The only true measure of scarcity is price …

In this lab we are going to take advantage of a database put together by David Jacks. The data for his paper “From Boom to Bust: A Typology of Real Commodity Prices in the Long Run” (2013, NBER Working Paper 18874) has consistent series of commodity prices for everything ranging from barley to zinc. For our lab we’ve selected prices since 1900.

We’re going to ask the following:

1. What has been the long-term trend in commodity prices?

2. Was Simon lucky to have won the bet?

3. Do commodity price trends differ by commodity in a way that we can understand? (This section will be more exploratory than in past labs. Here the important point is to report what you find, not to find a specific “right” answer.)

4. Finally, we will use our Malthusian “harvest” model to learn about renewable resources. (We may or may not get to this in class this week. If not, then this part of the lab will be pushed into next week, when we have no lab).

# Do not edit this chunk, but *do* press the green button to the answer key for the quiz info (the unreadable string below)
tot = 0
library(quizify)
source.coded.txt(answer.key)

Note: the most helpful reading for this lab is David Lam (2011), “How the World Survived the Population Bomb”

# Part 2. Visualizing commodity prices

Let’s see how the price of Chromium varies over time.

year.vec <- rownames(commod)
plot(year.vec, commod$Chromium, type = "l") abline(v = 1980) # the date of "the bet" Q2.1 How would you describe the history of Chromium prices? A. Steadily rising B. Steadily falling C. Very volatile, with little clear long-term trend D. Very volatile, with a clear upward trend ## "Replace the NA with your answer (e.g., 'A' in quotes)" answer2.1 = 'C' quiz.check(answer2.1) Your answer2.1 : C Correct. Explanation: There's clearly a lot of volatility. Although the price in 2015 is higher than in 1900, this doesn't look like a clear trend, since for much of the 20th century the price was lower than in 1900. ## What does “trendless” data look like? Imagine a “random walk”, in which prices go up or down each year by some random amount that averages zero. Each realization of this random walk will have, by luck, some trend, but the underlying process generating the randomness has no trend – on average the change is “zero”. It is very easy to falsely interpret a random walk as having an underlying trend. The subject of how to make inferences about the trend of a time series is covered in an econometrics or statistics class. For now, we will just look at some realizations of the random walk to get a feeling for what random realizations of trendless data can look like. ## here's the function plot.random.walk <- function(seed) { set.seed(seed) # this initializes the random # number generator used in # sample(). If we use the same # seed, we will get the same # set of "random" numbers. random.steps <- sample(x = c(-1,1), size = 40, replace = TRUE) ## this selects the number -1 or 1 randomly 40 times random.walk <- cumsum(random.steps) ## this turns the random steps into a walk by summing them up. ## cumsum(c(1,2,3)) returns a vector with values 1, 3, and 6. plot(1:40, random.walk, type = "l") } Here’s an example plot.random.walk(seed = 23) # Here we set seed to 23 Modify the code below to try 1,2, 3, and 4 as “seeds” plot.random.walk(seed = 23) plot.random.walk(seed = 23) plot.random.walk(seed = 23) plot.random.walk(seed = 23) Q.2.2 Which of the following seems to be true A. Even if price changes are random, averaging zero, the realization of a random process can look like it has a trend. B. A historical trend is the one reality we observe and we shouldn’t let anyone confuse us with alternative random realizations. C. Thinking about randomness may help us understand and interpret the reality we see and thus is a subject worth of study. ## "Replace the NA with your answer (e.g., 'A' in quotes)" answer2.2 = 'C' quiz.check(answer2.2) Your answer2.2 : C Sorry, incorrect. Try again. Hint: Ignore automatic message about your answer being 'incorrect.' .There is no 'correct' answer. But of course a professor would lean .toward 'C' ## Repeating for Tin Plot the price of tin. You can use the same code we used for Chromium, modifying just slightly. ## put your code for Tin here year.vec <- rownames(commod) plot(year.vec, commod$Tin, type = "l")
abline(v = 1980) 

## (Hint: you can copy and modify the commands we used for Chromium)

Q2.3 Why do you think Ehrlich chose Tin as one of his commodities to bet on?

1. Tin is difficult to substitute for

2. Tin had shown a sharp increase in price for the decade or so before 1980 and so it looked like it would continue.

3. The price had been going down before 1980 and was ready for a recovery

4. There was evidence that the tin mines were running out of ore

##  "Replace the NA with your answer (e.g., 'A' in quotes)"
quiz.check(answer2.3)
Your  answer2.3 : B
Correct.
Explanation:  Apparently, tin prices were controlled in part by a cartel of producers. See https://www.itri.co.uk/index.php?option=com_mtree&task=att_download&link_id=49605&cf_id=24 for a discussion from an industry research source.

# Part 3. Replicating actual bet

In the original bet, Ehrlich was allowed to choose any commodities he wished. He chose Chromium, Copper, Tin, Tungsten, and Nickel. In our data, we don’t have Tungsten. We can check to see if Simon still wins with the four commodities we have.

See the Lam reading, p. 1242 for an account of the bet.

We will use a function to compare commodities over time. This uses the indexing by label we did above. It returns the change in value of a $1000 purchase of the commodity basket in the start year. So if the function returns +100, this means that the value of the commodity basket increased by$100.

Q3.1 If the value of the basket increased by $100, who would win? A. Simon B. Ehrlich C. Neither, because the value of the basket doesn’t tell us if all of the commodities increased in price at the same time. ## "Replace the NA with your answer (e.g., 'A' in quotes)" answer3.1 = 'B' quiz.check(answer3.1) Your answer3.1 : B Correct. Explanation: An increase in prices suggests an increase in .'scarcity', what Ehrlich was betting on. bet.fun <- function(start, end, basket.vec, data) { ## start = 1980 ## end = 1990 ## data = commod ## basket.vec <- c("Copper", "Chromium", "Nickel", "Tin") year <- rownames(data) start.price <- data[year == start, basket.vec] end.price <- data[year == end, basket.vec] ## we invest 1000, buyin an equal$ amount in each commodity.
start.funds <- 1000
dollars.per.commod <- start.funds/length(basket.vec) # e.g. $250 with 4 ## amount purchased of each commodity holdings.vec <- dollars.per.commod/start.price ## value at the end value.at.end <- sum(holdings.vec * end.price) change.in.value <- value.at.end - start.funds return(change.in.value) } who.wins.fun <- function(change.in.value) { ifelse(change.in.value > 0, "ehrlich", "simon") } Let’s try this for 1980 to 1990 with Ehrlich’s basket. ehrlich.basket.vec <- c("Copper", "Chromium", "Nickel", "Tin") original.bet.result <- bet.fun("start" = 1980, "end" = 1990, "basket.vec" = ehrlich.basket.vec, "data" = commod) who.wins.fun(original.bet.result) [1] "simon" Q3.2 How much would Simon have won with our version of the “bet”? A. About 300 dollars B. He wouldn’t have won. He would have lost about 300 dollars C. About 500 dollars D. About 100 dollars ## "Replace the NA with your answer (e.g., 'A' in quotes)" answer3.2 = 'A' quiz.check(answer3.2) Your answer3.2 : A Correct. Explanation: A negative number means prices went down, and so Simon would have won. # Part 4. Does Simon win in other periods? Commodities are highly volatile. Even if commodities were generally rising, Ehrlich could have been unlucky about the timing of his bet. Let’s check over all years since 1900. We can construct a “loop” using R that will repeat the bet according to our instructions. We can then save the output in a vector and make a judgement about whether Ehrlich was simply unlucky. Here’s a simple example of a loop, in which we repeat an action 7 times, incrementing the value of “i”, and printing this value along with a label “iteration”. for (i in 1:7) ## the variable "i" takes the value 1, 2, 3, ... { ## anything in between {} is done once ## for each value that "i" takes print(c("iteration", i)) } [1] "iteration" "1" [1] "iteration" "2" [1] "iteration" "3" [1] "iteration" "4" [1] "iteration" "5" [1] "iteration" "6" [1] "iteration" "7"  Now let’s do a loop to see who won the bet in every year of the last century. start.vec <- 1900:2005 ## a vector of years to start the bet bet.result.vec <- rep(NA, length(start.vec)) ## an empty vector to be ## used to store the ## results names(bet.result.vec) <- start.vec ## labeling the elements (you can ignore) for (i in 1:length(start.vec)) { bet.result.vec[i] <- bet.fun(start = start.vec[i], end = start.vec[i] + 10, basket.vec = ehrlich.basket.vec, data = commod) } print(bet.result.vec)  1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 -258.700000 -156.431856 49.123809 -2.021327 -127.212088 -95.459327 -52.223399 -21.845369 293.912953 -175.917402 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 -424.804605 -552.181803 -531.713958 -479.901991 -406.828864 -457.454997 -483.863734 -488.154673 -501.451139 -259.693188 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 -81.082163 216.717344 243.454453 252.717049 341.054540 365.566495 331.228393 386.168194 276.108124 306.675598 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 392.074108 414.174885 351.395641 38.681985 -29.656863 -72.914365 -150.671378 -113.895743 74.669806 -21.202224 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 -3.043024 132.044717 202.843571 269.671205 213.919871 395.367748 542.721218 291.148075 176.863221 283.016148 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 92.501372 -34.354117 84.176895 16.043674 199.861978 170.674010 38.283426 107.300058 183.451841 109.764135 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 286.654596 400.477990 181.086693 314.033040 526.655925 591.149632 599.870085 591.992619 507.597248 647.651367 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 627.592390 308.600045 97.417259 -38.528232 -294.608549 -353.756361 -475.654892 -441.250784 71.947758 -57.956949 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 -306.220473 -275.830073 -193.578232 -353.610315 -237.373103 35.802145 16.675437 -96.471592 -524.143483 -588.938139 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 -354.297500 -393.554388 -372.843395 -10.989176 366.094672 68.122978 768.730531 1523.535732 2017.405153 1150.647495 2000 2001 2002 2003 2004 2005 1747.100492 2599.771715 2193.400721 1525.633810 609.806673 216.228316  To summarize our results, let’s look at them in several ways. Plot the numbers plot(start.vec, bet.result.vec) no non-missing arguments to min; returning Infno non-missing arguments to max; returning -InfError in plot.window(...) : need finite 'ylim' values In the graph, it looks like Ehrlich would have won more of the time. But not a lot more. Let’s tabulate how many times Ehrlich and Simon would have won: ## Convert to a vector of "simon" and "ehrlich", depending on who won winners.vec <- who.wins.fun(bet.result.vec) print(winners.vec)  1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 "simon" "simon" "ehrlich" "simon" "simon" "simon" "simon" "simon" "ehrlich" "simon" "simon" "simon" 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 "simon" "simon" "simon" "simon" "simon" "simon" "simon" "simon" "simon" "ehrlich" "ehrlich" "ehrlich" 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "simon" "simon" 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 "simon" "simon" "ehrlich" "simon" "simon" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 "ehrlich" "ehrlich" "ehrlich" "simon" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 "ehrlich" "simon" "simon" "simon" "simon" "simon" "ehrlich" "simon" "simon" "simon" "simon" "simon" 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 "simon" "ehrlich" "ehrlich" "simon" "simon" "simon" "simon" "simon" "simon" "simon" "ehrlich" "ehrlich" 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich" "ehrlich"  ## count number of times each won using the "table()" function table(winners.vec) winners.vec ehrlich simon 62 44  Q4.1 What percent of the time would Ehrlich have won of the 106 simulated bets from 1900 to 2005? A. About 62 percent B. About 58 percent ## "Replace the NA with your answer (e.g., 'A' in quotes)" answer4.1 = 'B' quiz.check(answer4.1) Your answer4.1 : B Correct. Explanation: 62/106 is about 0.58. Make a fancier plot. (You don’t need to understand this code.) plot(start.vec, bet.result.vec, type = "n") #an empty plot abline(h = 0) e <- which(winners.vec == "ehrlich") # T or F, to subset text() s <- which(winners.vec == "simon") text(x = start.vec[e], y = bet.result.vec[e], labels = "e", col = "blue") text(x = start.vec[s], y = bet.result.vec[s], labels = "s", col = "red") text(1960, 1500, "Ehrlich wins", col = "blue") text(1960, -250, "Simon wins", col = "red") # 5. Generalizing the bet to other commodities A change in the supply of a particular commodity may or may not cause a large price change – depending on the availability of substitutes. (Note: the results from this section will be useful for your write-up of the graded questions at the end of the lab.) The following code provides a template for a single commodity, in this case “Chromium”. start.vec <- 1900:2005 result.vec <- rep(NA, length(start.vec)) for (i in 1:length(start.vec)) { result.vec[i] <- bet.fun(start = start.vec[i], end = start.vec[i] + 10, basket.vec = c("Chromium"), data = commod) } winner.vec <- who.wins.fun(result.vec) cat("counts:\n") counts: table(winner.vec) winner.vec ehrlich simon 61 45  cat("proportions:\n") proportions: prop.table(table(winner.vec)) winner.vec ehrlich simon 0.5754717 0.4245283  Well done. You are finished with the computing portion of Lab 4. # Part 5. Graded Questions # 1. What relationship did Ehrlich expect to hold between commodity prices and population growth? Ehrlich expected population growth to invoke scarcity (and thus driving up commodity prices). As a Forbes article puts it, “Ehrlich insisted that commodities would become more expensive: they were running out in the face of the population explosion. Simon asserted the opposite: more people meant more brains meant better methods of extraction and lower usage per unit of production. Thus prices should fall. Simon won: but that’s not quite the end of the matter. With different commodities, or over different timescales with the same ones, Ehrlich could have.” # 2. Who won the bet in 1990? Given our analysis of other time periods, would you say that the winner was “lucky” or “right”, or both? [Explain your answer in 50 to 100 words.] Simon won in 1990, which was the end of the decade-duration bet. I agree with the Forbes article in that Simon was “lucky” in the time period the bet happened to occur in, and the commodities being betted upon. In our computational part of the lab, we found that over our investigated time period, Ehrlich had won about 58% of the time. So suppose Simon won to pure chance, at 42% (< 50%) chance. I’d call that lucky for a bet with money involved. (As noted in the lab, this section is for you to explore and describe what you found. Whether what you find is conclusive or inconclusive, you can still get full credit by reporting whatever you found.) ## 3. Choose another easily substitutable commodity from the database. Conduct the analysis of its price as the previous part of the lab and answer the following questions. # 3.1) Why do you think this commodity would be easily substitutable, explaining what “service” it provides with 1 or 2 sentences. I chose Coffee as the commodity to investigate, with a meta particular interest in whether or not this commodity is easily substitutable. Although this may cause difficulty in our analysis, I argue that there are many consumers who ‘require’ coffee to function, but theoretically it can be skipped upon. In fact, nowadays some people search for other sources of caffeine or taurine for this purpose. One could expect tea (another commodity in our data set) to be positively or negatively correlated with our coffee price trends. # 3.2) Attach a plot of the change of prices (“bet.result”) of the chosen commodity. ## get commodity data from a file on our server file <- "/data175/Real_commodity_prices_1900_2015.csv" commod <- read.table(file, sep = ",") # read the data into, with column header # head(commod) # looks at first few lines year.vec <- rownames(commod) plot(year.vec, commod$Coffee, type = "l")
abline(v = 1980)                        # the date of "the bet"

start.vec <- 1900:2005        ## a vector of years to start the bet
bet.result.vec <- rep(NA, length(start.vec)) ## an empty vector to be
## used to store the
## results
bet.fun <- function(start, end, basket.vec, data)
{
## start = 1980
## end = 1990
## data = commod
## basket.vec <- c("Coffee") # for this analysis we only look at a single commodity basket, of Coffee
year <- rownames(data)
start.price <- data[year == start, basket.vec]
end.price   <- data[year == end, basket.vec]
## we invest 1000, buyin an equal $amount in each commodity. start.funds <- 1000 dollars.per.commod <- start.funds/length(basket.vec) # e.g.$250 with 4 ; unnecessary for a single commodity basket
## amount purchased of each commodity
holdings.vec <- dollars.per.commod/start.price
## value at the end
value.at.end <- sum(holdings.vec * end.price)
change.in.value <- value.at.end - start.funds
return(change.in.value)
}
who.wins.fun <- function(change.in.value)
{
ifelse(change.in.value > 0, "ehrlich", "simon")
}
#
# names(bet.result.vec) <- start.vec ## labeling the elements (you can ignore)
# for (i in 1:length(start.vec))
# {
#     bet.result.vec[i] <- bet.fun(start = start.vec[i],
#                                  end = start.vec[i] + 10,
#                                  data = commod)
# }
# print(bet.result.vec)
winners.vec <- who.wins.fun(bet.result.vec)
plot(start.vec, bet.result.vec, type = "n") #an empty plot
no non-missing arguments to min; returning Infno non-missing arguments to max; returning -InfError in plot.window(...) : need finite 'ylim' values

Hint 1: there would only be your chosen commodity in the “basket.vec”. You can either modify the original “ehrlich.basket.vec” or create your own “basket.vec”. Remember to modify for-loop consistently.

Hint 2: you don’t need to show whether Ehrlich or Simon win about this commodity. But labelling the plot with different colors can help you understand the general trend.

Hint 3: NOT REQUIRED. To make it a better graph, you can add a title to the graph indicating the commodity you choose adding ‘main = “commodity name”’ to the syntax.

# 4. Choose a commodity from the database which you think would be hard to substitute for. And explain why you think this commodity would NOT be easily substituted, explaining what “service” it provides. (In 1 or 2 sentences) [Note: you don’t need to analyze the data for this problem.]

The most prime commodity that comes directly to mind is gold. As a commodity, it always has its uses from fashion to utility from electronics to other applications. Suppose demand for the utility for gold goes down. Then if the price drops, we can imagine more people would buy the dip for fashion purposes. It extends both ways. Moreover, we can’t forget the saying “it’s as good as gold.”

# 5. What are two reasons prices might not reflect the long-term availability of a commodity? [A sentence on each.]

Firstly, we only have current and past (historical) data on prices. Predicted or forecasted prices are dependent on future events, so we cannot use forecasted prices to implicate or draw inferences about the long-term availability of a commodity.

Secondly, we do not know how future technologies will affect the availability or demand for that given commodity. It may happen that a technology makes it so a competing commodity is much more useful than our first commodity, almost depleting demand for our first commodity, which would create a higher actual availability than predicted. Additionally, we could have a technology create new and better ways to provide more of our commodity, making the actual availability higher than projected and predicted. Alternatively, we could have new technologies actually require this commodity, which drives demand for the commodity higher and may make the actual long-term availability of the commodity much lower than projected.

# 6.1 There is a slight bug in the app, so that it reports sustainable yields even when harvest rate is unsustainable. How can you inspect the graphs to check on sustainability?

The app shows a harvest over time even when our harvest rate h is absurdly high. If the bottom-right chart says sustainable yield = 0, then we know we are over the harvest rate. It would end up looking like (due to our restrictions on zoom) our graph is discontinuous.

# 6.2 When h = 0.01, the sustainable yield is 0.0678, what is the sustainable yield when h = 0.02 and h = 0.04?

h = 0.02 => sustainable yield = 0.108 ; h = 0.04 => sustainable yield = 0.0239

# 6.3 What harvest rate maximizes the sustainable yield? [Hint: try all of the slider values]

At all other variables at default values (as in 6.2), we see that the sustainable yield increases as x goes from 0 to 0.022, then starts decreasing indefinitely. So the harvest rate h = 0.022 gives the maximum sustainable yield for our discrete measures.

# 6.4 What harvest rate maximizes the yield during the first year of harvesting (this is about year 10 on the slider, or year 0 on the time axes of the graph)? (You can either report the value you find with the “app” or your theoretical answer)

Considering only the sustainable yield at t= 10 on the slider (t = 0 on graph), we see the yield is constant at 0 for all values of h. Perhaps the questions should ask us to look at the range t = 10 to t = 20, and take the “area under the curve” for this region. Investigating this, we see that the first year’s harvest yield strictly increases as we increase h (even when inducing the “bug” where it’s past sustainability).

So for the harvest rate that maximizes the first year’s total yield from harvesting, we take the highest h value that is still sustainable, which is at about h = 0.076.

# 6.5 Would harvest rates be higher in year “1” if we harvested at the sustainable rate found in part 6.3, or if they were .02 higher than the sustainable rate?

The harvest rates would be higher at h = 0.022 + 0.02 compared to h = 0.022, based on the trend we discussed the previous problem (that the harvest rates in year 1 increase with higher values of h). We verify this in the app. If we are comparing h = 0.022 to h = 0.076 + 0.02, then we can expect the first year’s harvest to be higher at 0.02 past the sustainable rate. Although our results are good for the first year, we can expect our harvest rates to be worse eventually.

# 6.6 When Becker advocates for attention to sustainability, how did Lam reply to his warning? (In 1 or 2 sentences).

Lam notes “Although I agree with Becker’s concern about water, I am less concerned that we will run out of oil or any other resource that has clear property rights and active markets. ( https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4298828/ )”. Lam draws a distinction between protected/restricted resources and free resources like water, in terms of attention to sustainability.

On discussing the illegal loging problem in Indonesia, he writes “The point is that it will take institutional change, not simply the end of population growth, to solve the problem.” Essentially, Lam agrees with the call for attention to sustainability, but he adds notes that stopping population growth is not the only factor involved in the solution.

Congratulations! You are finished with Lab 4.