library(GFPMoutput)
library(knitr)
library(dplyr)
library(ggplot2)
library(scales)
# Github flavoured markdown for tables
# http://stackoverflow.com/questions/28687826/how-to-generate-a-github-flavoured-markdown-file-using-knitr
options(knitr.table.format = 'markdown')
# Set same path for knitr evaluation as for interactive use
opts_knit$set(root.dir = '../..')
opts_chunk$set(fig.width=10)

Load scenario data

If you created a scenario with the load_and_clean_gfpm_data() function, your scenario will be stored in the enddata folder. The data object used for demonstration purposes is called trainingscenarios. It is a list of data frames.

basescenario <- readRDS("enddata/basescenario.rds")
trainingscenarios <- readRDS("enddata/GFPM_training_scenarios.rds")

To bind several scenarios together in one list, use the bindscenarios() function.

What is the structure of "trainingscenarios"

trainingscenarios is a list of data frames:

str(trainingscenarios)

You can extract individual data frames with the command:

countrydata <- trainingscenarios$entity 
regiondata <- trainingscenarios$aggregates 

How many periods are there per scenario?

trainingscenarios$aggregates %>% group_by(Scenario) %>% 
    summarise(number_of_periods = max(Period)) %>% kable()
# Remove periods for base2011 so that all scenarios have the same periods for plotting
trainingscenarios$aggregates <- trainingscenarios$aggregates %>%
    filter(Period <= 5)
trainingscenarios$entity <- trainingscenarios$entity %>%
    filter(Period <= 5)

What products are demanded, supplied, produced or traded ?

trainingscenarios$entity %>% group_by(Element) %>%
    summarise(Products = paste(unique(Product),collapse=", ")) %>% kable()

What countries are in the simulation?

countries <- sort(unique(trainingscenarios$entity$Country))
# Convert to utf8 because of character encoding issue
cat(iconv(countries,"latin1","UTF-8"),sep= ", ")

Plots

Plot by region

plotprodbyreg(trainingscenarios, "Sawnwood", "Base")
plotprodbyreg(trainingscenarios, "IndRound", "Base")

Plot by country

Sample plot for Sanwood demand in the base scenario, in France and Germany.

plotprodbycounty(trainingscenarios, "Sawnwood", "Base",
                 c("France", "Germany"))

The above function generates a plot based on the given arguments. For greater flexibility you are encouraged to read about ggplot2 package. Here is an example plot showing demand, export, import and production of selected panel products in the United States in the base scenario.

usademand <- trainingscenarios$entity %>% 
    filter(Country == "United States of America" & 
               Element %in% c("Demand", "Production",
                              "Import", "Export") &
               Product %in% c("ParticleB", "FiberB","Plywood") &
               Scenario == "Base")

ggplot(data=usademand) +
    aes(x=Period, y=Volume, colour=Product) +
    geom_line() + 
    theme(legend.position = "bottom") +
    facet_grid(~ Element) 

Example of a description for this graph. The base scenario simulated a decrease in particle board production and an increase in demand over the 5 periods. The increased particle board demand was compensated by increases in imports. On the other hand fibre board and plywood import decreased over the period.

Compare scenarios

Two training scenarios where calculated by changing the demand elasticities by plus or minus 1 standard error, corresponding to a confidence intereval of 70%.

sawnwood <- subset(trainingscenarios$aggregates, Product=="Sawnwood"& Element=="Demand")
ggplot(data = sawnwood) +
    aes(x = Period, y = Volume, colour = GFPM_REG, linetype = Scenario) +
    geom_line() + ggtitle("Sawnwood Demand") +
    theme(legend.position = "bottom")

Compare for all products

paperproducts <- subset(trainingscenarios$aggregates, Element=="Demand" & 
                  ! Product %in% c("MechPlp", "ChemPlp", "WastePaper"))
ggplot(data = paperproducts) +
    aes(x = Period, y = Volume, colour = GFPM_REG, linetype = Scenario) +
    geom_line() + ggtitle("Demand") +
    theme(legend.position = "bottom") + facet_wrap(~Product, scales="free_y")


paul4forest/GFPMoutput documentation built on May 24, 2019, 8:25 p.m.