Table of Contents
# 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

Explore Sawnwood

\[\beta_1\]

Consumption, production, trade and net trade in the European Union

In the following file, we explore a data table containing Sawnwood 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          Total Sawnwood          85         99        14     34     48  0
## 155     Sawnwood Coniferous          76         89        13     30     43  0
## 156 Sawnwood Non Coniferous           9         10         0      4      5  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).

plot of chunk consumptionTotalEU

Consumption at the country level

Apparent consumption of Sawnwood 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")

plot of chunk consumptionbyCountry

Prices

EU prices

Average trade price of Sawnwood 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))

plot of chunk priceEU

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).

plot of chunk priceComparison

Trade prices by country

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.Export Quantity.Export Value.Export Price_Trade.Export Price_EUR.Import Quantity.Import Value.Import Price_Trade.Import
1 United Kingdom -4980633.00 253.72 140599.00 54236.00 368.99 253.72 5121232.00 1721105.00 321.47
2 Italy -4618000.00 218.91 273000.00 174564.00 611.65 218.91 4891000.00 1328737.00 259.87
3 France -2231685.00 250.13 837612.00 272329.00 311.00 250.13 3069297.00 1027228.00 320.14
4 Netherlands -2152900.00 257.00 421400.00 191452.00 434.59 257.00 2574300.00 832351.00 309.28
5 Germany 2384480.00 211.95 6696793.00 1787723.00 255.35 211.95 4312313.00 1315190.00 291.74
6 Romania 3178064.00 202.23 3225382.00 852608.00 252.86 202.23 47318.00 27526.00 556.45
7 Austria 3241112.00 207.90 5178107.00 1377928.00 254.55 207.90 1936995.00 589193.00 290.96
8 Finland 5992371.00 186.31 6448910.00 1596194.00 236.76 186.31 456539.00 114671.00 240.26
9 Sweden 11450088.00 210.15 11853000.00 3272317.00 264.08 210.15 402912.00 152689.00 362.50
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))

plot of chunk tradePricesByCountry

Plot log of the estimation data

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.

Total Sawnwood

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")

plot of chunk unnamed-chunk-1

Explore the influence of Year and Net_Trade by country

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))  

plot of chunk unnamed-chunk-2