# See source for more details on input, output from the author
library(ggplot2)
library(reshape2)
library(plyr)
options(width=80)
dtf <- product.data$entity
agg <- product.data$eu_aggregates
trade <- product.data$trade
\[\beta_1\]
In the following file, we explore a data table containing Paper and Paperboard consumption data for 28 countries from 1961 to 2012. In 2012, the overall EU consumption, production and trade in million Tons per item was:
## Item Consumption Production Net_Trade Import Export
## 205 Total Paper and Paperboard 81 93 12 49 61
## 206 Newsprint 7 8 0 5 5
## 207 Printing and Writing Paper 25 32 7 20 27
## 208 Other Paper and Paperboard 49 53 4 24 28
## NA NA
## 205 0 0
## 206 0 0
## 207 0 0
## 208 0 0
#summary(agg)
ggplot(data=subset(agg, !Element%in%c("Import_Value", "Export_Value","Price"))) +
geom_line(aes(x=Year, y=Value/1e6, colour=Item),size=1) +
facet_wrap(~Element) +
ylab(paste("Million",product.data$metadata$unit)) + theme_bw()
## Warning: Removed 68 rows containing missing values (geom_path).
## Warning: Removed 68 rows containing missing values (geom_path).
Apparent consumption of Paper and Paperboard by country
ggplot(data=dtf) +
geom_line(aes(x=Year, y=Consumption/1e+06, colour=Item), size=1) +
facet_wrap(~Country, scales = "free_y") +
xlab("Year") +
ylab(paste("Million",product.data$metadata$unit)) +
theme_bw() + theme(legend.position="bottom")
Average trade price of Paper and Paperboard in the European Union
# Rename Price to Price USD (Use level because Element is a factor)
levels(agg$Element)[levels(agg$Element)=="Price"] <- "Price_real_USD"
ggplot(data=subset(agg, Element=="Price_real_USD")) +
geom_line(aes(x=Year, y=Value, color=Item)) +
ylab(paste("Price in (2010) constant USD /", product.data$metadata$unit))
Comparison of nominal price in USD and real price in USD and EUR.
p <- dcast(agg, Year + Item ~ Element, value.var="Value")
# Add US and EUR deflator in the plot for information
p <- merge(p, EUR[c("Year", "DeflEUR")])
p <- merge(p, US[c("Year", "DeflUS")])
p <- mutate(p,
Price_Nominal_USD = (Import_Value + Export_Value)/
(Import_Quantity + Export_Quantity) *1000,
Price_USD_2 = Price_EUR /ExchR)
p <- p[c("Year", "Item", "Price_Nominal_USD", "DeflUS",
"Price_real_USD", "DeflEUR", "ExchR", "Price_EUR")]
p <- melt(p, id=c("Year","Item"), variable.name="Element", value.name="Value")
ggplot(data=p) +
geom_line(aes(x=Year, y=Value, color=Item)) +
facet_wrap(~ Element, ncol=1, scales = "free_y")
## Warning: Removed 68 rows containing missing values (geom_path).
## Warning: Removed 68 rows containing missing values (geom_path).
Prices expressed in constant US dollars of 2010 per Tons.
Import_Price = Import_Value / Import_Quantity / DeflUS*1000
Export_Price = Export_Value / Export_Quantity / DeflUS*1000
Trade prices for the 9 countries which have the highest trade volume in 2012 (volumes are in Tons).
Country | Net_Trade | Price_EUR.Export | Quantity.Export | Value.Export | Price_Trade.Export | Price_EUR.Import | Quantity.Import | Value.Import | Price_Trade.Import | |
---|---|---|---|---|---|---|---|---|---|---|
1 | United Kingdom | -4928264.00 | 399.09 | 1190736.00 | 1660317.00 | 778.77 | 399.09 | 6119000.00 | 5904727.00 | 538.95 |
2 | Italy | -1677030.00 | 366.90 | 3074833.00 | 3288885.00 | 597.39 | 366.90 | 4751863.00 | 4157839.00 | 488.69 |
3 | Poland | -978110.00 | 359.07 | 2107532.00 | 1958435.00 | 519.00 | 359.07 | 3085642.00 | 2877239.00 | 520.79 |
4 | France | -955612.00 | 388.41 | 4295085.00 | 4530507.00 | 589.12 | 388.41 | 5250697.00 | 5084332.00 | 540.82 |
5 | Belgium | -732113.00 | 310.26 | 2462717.00 | 1923204.00 | 436.16 | 310.26 | 3194830.00 | 2628783.00 | 459.56 |
6 | Germany | 2592000.00 | 379.42 | 13523000.00 | 13531664.00 | 558.87 | 379.42 | 10931000.00 | 10529147.00 | 537.98 |
7 | Austria | 2750965.00 | 333.24 | 4128690.00 | 3453272.00 | 467.14 | 333.24 | 1377725.00 | 1305252.00 | 529.13 |
8 | Sweden | 9088984.00 | 353.03 | 9961805.00 | 9078691.00 | 509.00 | 353.03 | 872821.00 | 840398.00 | 537.76 |
9 | Finland | 9420792.00 | 350.46 | 9882541.00 | 8986250.00 | 507.86 | 350.46 | 461749.00 | 415011.00 | 501.98 |
ggplot(data=subset(trade, Country %in% countries)) +
geom_line(aes(x=Year, y=Price_Trade, color=Item, linetype = Trade))+
facet_wrap( ~ Country, ncol = 3) +
ylab(paste("Price in (2010) constant USD /", product.data$metadata$unit))
We will estimate the model \[ log(Consumption) = \beta_0 + \beta_1 log(GDP) + \beta_2 log(Price) + \beta_3 log(Consumption_{t-1}) \]
Lets look at the relationship between log(Consumption) and log(GDP) first.
plot(log(Consumption) ~ log(GDPconstantUSD),
data=dtf[grep("Total", dtf$Item),])
points(log(Consumption) ~ log(GDPconstantUSD),
data=dtf[grepl("Total", dtf$Item) & dtf$Year>2011,], col="red")
Sort countries by Net_Trade, then display a color for each country
dtf_last = dtf[grepl("Total", dtf$Item) & dtf$Year==max(dtf$Year),]
dtf_last = dtf_last[order(dtf_last$Net_Trade),]
dtf$Country = factor(dtf$Country, levels= dtf_last$Country, ordered=TRUE)
p = ggplot(dtf, aes(x=log(GDPconstantUSD), y=log(Consumption))) + facet_wrap(~Item)
p + geom_point(aes(alpha=Year, color=Country))