Capitalism II

Materials for class on Wednesday, January 9, 2019

Contents

Slides

Download the slides from today’s lecture.

First slide

Adjusting for inflation

Converting nominal values (the numbers written down at the time) to real values (the numbers in today’s / another year’s dollars):

\[ \text{Real value} = \frac{\text{Nominal value}}{\text{Price index / 100}} \]

Shifting the price index to a different year:

\[ \text{Price index}_{\text{new year}} = \frac{\text{Price index}_{\text{current year}}}{\text{Price index}_{\text{new year}}} \times 100 \]

Or, for the quickest and easiest method, use the BLS’s CPI inflation calculator.

Calculating the inflation rate

The inflation rate is the percent change in CPI between two periods. The formula for percent change is:

\[ \text{% change} = \frac{\text{New} - \text{Old}}{\text{Old}} \]

or

\[ \text{% change} = \frac{\text{Current} - \text{Previous}}{\text{Previous}} \]

The CPI in January 2010 was 217.488, and it was 249.245 in January 2018. The total inflation over the past 8 years is \(\frac{249.245 - 217.488}{217.488}\), or 14.6%.

Economic indicators

You can download each of these indicators by hand and then compile them into an Excel spreadsheet, or you can use the tidyquant R package to access this data from the FRED API and compile them all automatically, like magic.

Here are a couple spreadsheets I compiled for you. The code for downloading and compiling this data is below:

library(tidyverse)  # Load ggplot, dplyr, tidyr, and friends
library(tidyquant)  # Download FRED data and other quantitative financial data
library(lubridate)  # Do cool stuff with dates

# tribble() lets you make a miniature dataframe
code_names <- tribble(
  ~symbol,            ~title,
  "GDP",              "GDP",
  "GDPDEF",           "GDP deflator",
  "CPIAUCSL",         "CPI",
  "A792RC0A052NBEA",  "Personal income per capita",
  "PINCOME",          "Personal income",
  "HLTHSCPCHCSA",     "Health expenditures per capita",
  "POPTOTUSA647NWDB", "Population"
)

# Download all those codes from FRED from 1979 to 2018
fred_raw <- tq_get(code_names, 
                   get = "economic.data",
                   from = "1979-01-01", to = "2018-12-31")

# tq_get downloads this data in tidy (long) format. spread() reshapes this data
# so that there's a column for each indicators. filter() makes sure we only look
# at January.
fred <- fred_raw %>% 
  select(-symbol) %>% 
  spread(title, price) %>% 
  filter(month(date) == 1)

# Look at the first few rows
head(fred)

# Save as a CSV file
write_csv(fred, "fred_stuff.csv")

# Or save as an Excel file
library(writexl)
write_xlsx(fred, "fred_stuff.xlsx")

Clearest and muddiest things

Go to this form and answer these three questions:

  1. What was the muddiest thing from class today? What are you still wondering about?
  2. What was the clearest thing from class today?
  3. What was the most exciting thing you learned?

I’ll compile the questions and send out answers after class.