KLEMS (1)

Emrah Er bio photo By Emrah Er

This post is actually a homework I did. The data file contains input use, output, quantities, costs, and prices for total U.S. nondurable manufacturing for 1949-2001.

The data are defined as follows:

  • , , , , = Inputs corresponding to capital, labor, energy, materials, and purchased services,
  • = represents total output,
  • = respective quantity indexes,
  • = respective values/costs (nominal terms in $billions),
  • = respective price indexes,
  • = respective cost shares.

We conducted an analysis that is similar to Berndt and Wood (1975) and Binswanger, H. P. (1974).

Questions in the homework were:

  • Estimating the parameters of the cost function by estimating a system of factor demand equations.
  • Testing linear homogeneity (within-equation adding-up) and symmetry.
  • Testing for structural change that occurred with a discrete break in 1973 in the factor demand system.
  • Estimating the output-constant, factor-demand price elasticities, the Allen and Morishima elasticities of substitution at the mean values of the data.

The translog cost function given was:

Factor demand equations can be found from the given translog cost function by using Shephard’s Lemma:

By using factor demand equations we can estimate the parameters of the cost function. In order to do this we have to impose symmetry and homogeneity restrictions and estimate the system of demand equations. We can drop Services () equation while estimating the system and recover its parameters by using the imposed restrictions. We have to use the following restrictions:

To call the required packages and to import the data file into R I used the following commands

library(xtable)
library(knitr)
library(systemfit)
library(micEcon)
library(AER)
library(strucchange)
library(RCurl)
url <- "https://raw.githubusercontent.com/emraher/data/master/klems.csv"
data <- getURL(url)
data <- read.csv(textConnection(data))

Using the imported data I have created new series. I have done this by using the following commands:

# Create new series
# ----------------------------------------------------------
data$q <- log(data$y_q)
data$py <- log(data$y_p)
data$pk <- log(data$k_p)
data$pl <- log(data$l_p)
data$pe <- log(data$e_p)
data$pm <- log(data$m_p)
data$ps <- log(data$s_p)
data$c <- data$k_v + data$l_v + data$e_v + data$m_v + data$s_v
data$ss_k <- data$k_v/data$c
data$ss_l <- data$l_v/data$c
data$ss_e <- data$e_v/data$c
data$ss_m <- data$m_v/data$c
data$ss_s <- data$s_v/data$c

To plot the series I have created new data frames which are in time series format and then used ts.plot. Probably there are other and easier ways to this (using ggplot2 maybe) but I used the following codes:

attach(data)
# Create new dataframes and TS data
# ----------------------------------------------------------
quantities <- data.frame(y_q = y_q, k_q = k_q, l_q = l_q, e_q = e_q, m_q = m_q, 
    s_q = s_q)
quantities.ts <- ts(quantities, start = 1949, frequency = 1)
prices <- data.frame(y_p = y_p, k_p = k_p, l_p = l_p, e_p = e_p, m_p = m_p, 
    s_p = s_p)
prices.ts <- ts(prices, start = 1949, frequency = 1)
log.prices <- data.frame(py = py, pk = pk, pl = pl, pe = pe, pm = pm, ps = ps)
log.prices.ts <- ts(log.prices, start = 1949, frequency = 1)
shares <- data.frame(ss_k = ss_k, ss_l = ss_l, ss_e = ss_e, ss_m = ss_m, ss_s = ss_s)
shares.ts <- ts(shares, start = 1949, frequency = 1)

Here are the codes for producing the graphs.

# Define colors, names of series and plot area size
# ----------------------------------------------------------
plot_colors <- c("red", "blue", "black", "green", "magenta", "brown")
series_names <- c("Y", "K", "L", "E", "M", "S")
par(mar = c(4.1, 4.1, 4.1, 6.1), xpd = TRUE)
# US Manufacturing Quantities
# ----------------------------------------------------------
ts.plot(quantities.ts, gpars = list(xlab = "Year", ylab = "Quantities", main = "US Manufacturing Quantities", 
    lwd = 2, lty = c(1:6)), col = plot_colors)
legend("right", series_names, inset = -0.2, lwd = 1, lty = c(1:6), col = plot_colors, 
    horiz = F, cex = 0.8)

plot of chunk unnamed-chunk-4

# Define colors, names of series and plot area size
# ----------------------------------------------------------
plot_colors <- c("red", "blue", "black", "green", "magenta", "brown")
series_names <- c("Y", "K", "L", "E", "M", "S")
par(mar = c(4.1, 4.1, 4.1, 6.1), xpd = TRUE)
# US Manufacturing Prices
# ----------------------------------------------------------
ts.plot(prices.ts, gpars = list(xlab = "Year", ylab = "Prices", main = "US Manufacturing Prices", 
    lwd = 2, lty = c(1:6)), col = plot_colors)
legend("right", series_names, inset = -0.2, lwd = 1, lty = c(1:6), col = plot_colors, 
    horiz = F, cex = 0.8)

plot of chunk unnamed-chunk-5

# Define colors, names of series and plot area size
# ----------------------------------------------------------
plot_colors <- c("red", "blue", "black", "green", "magenta", "brown")
series_names <- c("Y", "K", "L", "E", "M", "S")
par(mar = c(4.1, 4.1, 4.1, 6.1), xpd = TRUE)
# US Manufacturing Log-Prices
# ----------------------------------------------------------
ts.plot(log.prices.ts, gpars = list(xlab = "Year", ylab = "Log Prices", main = "US Manufacturing Log-Prices", 
    lwd = 2, lty = c(1:6)), col = plot_colors)
legend("right", series_names, inset = -0.2, lwd = 1, lty = c(1:6), col = plot_colors, 
    horiz = F, cex = 0.8)

plot of chunk unnamed-chunk-6

# Define colors, names of series and plot area size
# ----------------------------------------------------------
plot_colors <- c("red", "blue", "black", "green", "magenta")
par(mar = c(4.1, 4.1, 4.1, 6.1), xpd = TRUE)
# US Manufacturing Cost Shares
# ----------------------------------------------------------
ts.plot(shares.ts, gpars = list(xlab = "Year", ylab = "Share", main = "US Manufacturing Cost Shares", 
    lwd = 2, lty = c(1:5)), col = plot_colors)
series_names <- c("K", "L", "E", "M", "S")
legend("right", series_names, inset = -0.2, lwd = 1, lty = c(1:5), col = plot_colors, 
    horiz = F, cex = 0.8)

plot of chunk unnamed-chunk-7