# 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 Roundwood consumption data for 28 countries from 1961 to 2012. In 2012, the overall EU consumption, production and trade in million M3 per item was:
## Item Consumption Production Net_Trade Import Export NA
## 154 Roundwood Coniferous 287 281 -6 28 22 0
## 155 Roundwood Non Coniferous 152 145 -6 19 13 0
## 156 Total Roundwood 439 427 -12 52 40 0
## NA
## 154 0
## 155 0
## 156 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 51 rows containing missing values (geom_path).
## Warning: Removed 51 rows containing missing values (geom_path).
Apparent consumption of Roundwood 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 Roundwood 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 51 rows containing missing values (geom_path).
## Warning: Removed 51 rows containing missing values (geom_path).
Prices expressed in constant US dollars of 2010 per M3.
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 M3).
Country | Net_Trade | Price_EUR.Import | Quantity.Import | Value.Import | Price_Trade.Import | Price_EUR.Export | Quantity.Export | Value.Export | Price_Trade.Export | |
---|---|---|---|---|---|---|---|---|---|---|
1 | Austria | -7157412.00 | 75.81 | 8041736.00 | 804270.00 | 95.67 | 75.81 | 884324.00 | 95536.00 | 103.34 |
2 | Sweden | -6598577.00 | 52.21 | 7334000.00 | 486208.00 | 63.42 | 52.21 | 735423.00 | 74092.00 | 96.37 |
3 | Finland | -4855799.00 | 56.02 | 5552685.00 | 391125.00 | 67.38 | 56.02 | 696886.00 | 74428.00 | 102.16 |
4 | Belgium | -3692356.00 | 53.01 | 4829591.00 | 279237.00 | 55.31 | 53.01 | 1137235.00 | 141393.00 | 118.93 |
5 | Italy | -3616403.00 | 72.88 | 3793463.00 | 358102.00 | 90.30 | 72.88 | 177060.00 | 26699.00 | 144.24 |
6 | Germany | -3399994.00 | 71.87 | 6861911.00 | 625369.00 | 87.18 | 71.87 | 3461917.00 | 361354.00 | 99.85 |
7 | Czech Republic | 1915460.00 | 76.91 | 1980496.00 | 198124.00 | 95.69 | 76.91 | 3895956.00 | 402868.00 | 98.91 |
8 | Latvia | 3645263.00 | 46.55 | 738943.00 | 49200.00 | 63.69 | 46.55 | 4384206.00 | 267934.00 | 58.46 |
9 | France | 4058920.00 | 56.97 | 1291767.00 | 155374.00 | 115.05 | 56.97 | 5350687.00 | 347820.00 | 62.18 |
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))