Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comment #102

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '8096160'
ValidationKey: '8116605'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'mrdrivers: Create GDP and Population Scenarios'
version: 4.0.4
date-released: '2024-11-13'
version: 4.0.5
date-released: '2024-11-14'
abstract: Create GDP and population scenarios This package constructs the GDP and
population scenarios used as drivers in both the REMIND and MAgPIE models.
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mrdrivers
Type: Package
Title: Create GDP and Population Scenarios
Version: 4.0.4
Version: 4.0.5
Authors@R: c(person(given = "Johannes",
family = "Koch",
email = "[email protected]",
Expand Down Expand Up @@ -44,6 +44,6 @@ Suggests:
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Date: 2024-11-13
Date: 2024-11-14
Config/testthat/edition: 3
VignetteBuilder: knitr
7 changes: 4 additions & 3 deletions R/toolHarmonizeGDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ toolSHAPEgrowth <- function(shapeGDPScenario, gdppcapSSP1, startFromYear) {
stop("cannot create SHAPE GDP scenarios: unknown scenario")
}

# for service (SDP_MC) and society (SDP_RC) additionally add a smoothing for 2020 and 2025 timesteps
# apply only 1/3 (2020-2024) and 2/3 (2025-2029) of the modification
# For service (SDP_MC) and society (SDP_RC) additionally add a smoothing for the first two 5-year timesteps
# (2025 and 2030 with current default startFromYear = 2025)
# Apply only 1/3 of the modification for first 5 years, and 2/3 of the modification for another 5 years
if (shapeGDPScenario %in% c("SDP_MC", "SDP_RC")) {
if (yr >= startFromYear && yr < startFromYear + 5) {
modificationFactor[, yr, ] <- 1 / 3. * (modificationFactor[, yr, ] - 1) + 1
Expand All @@ -274,7 +275,7 @@ toolSHAPEgrowth <- function(shapeGDPScenario, gdppcapSSP1, startFromYear) {
growthrate[, yr, ] <- growthrate[, yr, ] * modificationFactor[, yr, ]
}

# calculate next gdp/cap based on current value and (modified) growth rate
# Calculate next gdp/cap based on current value and (modified) growth rate
gdppcap[, yr + as.integer(timestep[, yr, ]), ] <- gdppcap[, yr, ] * (1 + growthrate[, yr, ] / 100.)^timestep[, yr, ]
}

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create GDP and Population Scenarios

R package **mrdrivers**, version **4.0.4**
R package **mrdrivers**, version **4.0.5**

[![CRAN status](https://www.r-pkg.org/badges/version/mrdrivers)](https://cran.r-project.org/package=mrdrivers) [![R build status](https://pik-piam.github.io/mrdrivers/workflows/check/badge.svg)](https://pik-piam.github.io/mrdrivers/actions) [![codecov](https://codecov.io/gh/mrdrivers/branch/master/graph/badge.svg)](https://app.codecov.io/gh/mrdrivers) [![r-universe](https://pik-piam.r-universe.dev/badges/mrdrivers)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -100,7 +100,7 @@ In case of questions / problems please contact Johannes Koch <jokoch@pik-potsdam

To cite package **mrdrivers** in publications use:

Koch J, Soergel B, Leip D, Benke F, Dietrich J (2024). _mrdrivers: Create GDP and Population Scenarios_. R package version 4.0.4, <https://pik-piam.github.io/mrdrivershttps://github.com/pik-piam/mrdrivers>.
Koch J, Soergel B, Leip D, Benke F, Dietrich J (2024). _mrdrivers: Create GDP and Population Scenarios_. R package version 4.0.5, <https://pik-piam.github.io/mrdrivershttps://github.com/pik-piam/mrdrivers>.

A BibTeX entry for LaTeX users is

Expand All @@ -109,7 +109,7 @@ A BibTeX entry for LaTeX users is
title = {mrdrivers: Create GDP and Population Scenarios},
author = {Johannes Koch and Bjoern Soergel and Deborra Leip and Falk Benke and Jan Philipp Dietrich},
year = {2024},
note = {R package version 4.0.4},
note = {R package version 4.0.5},
url = {https://pik-piam.github.io/mrdrivers},
url = {https://github.com/pik-piam/mrdrivers},
}
Expand Down
108 changes: 64 additions & 44 deletions vignettes/scenarios.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,61 @@ editor_options:
chunk_output_type: console
---

# Available Scenarios
# Default scenarios

The tool function `toolGetScenarioDefinition()` can be used to see what driver/scenario options are available.
By default, the following scenarios are returned for all drivers:

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
- the SSPs, i.e. SSP1-5
- the SDPs, i.e. SDP, SDP_EI, SDP_MC and SDP_RC
- (SSP2EU - deprecated, but still returned as a placeholder. Identical to SSP2)

```{r setup, echo=FALSE, message=FALSE}
library(mrdrivers) # nolint
library(magrittr) # nolint
```
The scenarios span from 1960 to 2150, with yearly data until 2030, and data every 5 years thereafter.

```{r}
toolGetScenarioDefinition() %>% print(n = 200)
```
## GDP per capita and GDP

# User Defined Scenarios
### SSPs

The user can create custom scenarios by creating a tibble called "mrdivers_scenarios" in the global environment, and filling it with the desired scenario definitions. The structure of the "mrdivers_scenarios" object should be identical to that of the return object of `toolGetScenarioDefinition()`, and the scenario building blocks have to be available. For example, say the user wanted to create SSP scenarios, but without using the Missing Islands data-set. The following command executed in the global environment would make the "nomi" (no-missing islands) scenario available.
Suggested overall reference for the scenario construction: Koch and Leimbach 2023 ([link](https://doi.org/10.1016/j.ecolecon.2023.107751)).

```{r}
mrdrivers_scenarios <- tibble::tribble( # nolint
~driver, ~scenario, ~pastData, ~futureData, ~harmonization,
"GDPpc", "nomi", "WDI", "SSPs", "GDPpcSSPs",
"Population", "nomi", "WDI", "SSPs", "PopSSPs",
"GDP", "nomi", "-", "-", "GDPpcWithPop"
)
```
The SSP GDP per capita scenarios are constructed using:

- WDI data ([link](https://databank.worldbank.org/source/world-development-indicators)) from 1990 to 2022 (missing country data filled in with MI data ([link](https://doi.org/10.5281/zenodo.4421504)) and James data ([link](https://pophealthmetrics.biomedcentral.com/articles/10.1186/1478-7954-10-12), specifically the WB_ID series) extended backwards until 1960 using growth rates from MI and James,

# Default Scenarios
- growth rates from IMF GDP per capita projections ([link](https://www.imf.org/-/media/Files/Publications/WEO/WEO-Database/2022/WEOOct2022all.ashx)) until 2029,

By default, the following scenarios are returned for all drivers:
- and SSP GDP per capita projections (SSP OECD projections [link](https://data.ece.iiasa.ac.at/ssp/#/about), release 3.0.1 (March 2024)) until 2100.

- the SSPs, i.e. SSP1-5
- the SDPs, i.e. SDP, SDP_EI, SDP_MC and SDP_RC
The scenarios are extended until 2150 using a bezier curve method that assumes that the slope in 2100 is flattened by half by 2150. For countries lacking projection data, the last historical data point is used in all future years. For more details on the harmonization, see Koch and Leimbach 2023 ([link](https://doi.org/10.1016/j.ecolecon.2023.107751)).

The scenarios span from 1960 to 2150, with yearly data until 2030, and data every 5 years thereafter.
The SSP GDP scenarios are the product of the GDP per capita and population scenarios.

# References
### SDPs

## GDP per capita and GDP scenarios
Suggested overall reference for the SDP scenarios: Bjoern Soergel et al 2024 Environ. Res. Lett. 19 124009 ([link](http://dx.doi.org/10.1088/1748-9326/ad80af)).

### SSPs
The SDP GDP per capita scenarios are all based off of SSP1, with different harmonization functions for the different SDPs.

Suggested overall reference for the scenario construction: Koch and Leimbach 2023 ([link](https://doi.org/10.1016/j.ecolecon.2023.107751)).
The SDP GDP scenarios are the product of the GDP per capita and population scenarios.

The SSP GDP per capita scenarios are constructed using past WDI data ([link](https://databank.worldbank.org/source/world-development-indicators)) from 1990 to 2022 (missing country data filled in with MI data ([link](https://doi.org/10.5281/zenodo.4421504)) and James data ([link](https://pophealthmetrics.biomedcentral.com/articles/10.1186/1478-7954-10-12), specifically the WB_ID series), extended backwards until 1960 using growth rates from MI and James), growth rates from IMF GDP per capita projections ([link](https://www.imf.org/-/media/Files/Publications/WEO/WEO-Database/2022/WEOOct2022all.ashx)) until 2029, and SSP GDP per capita projections (SSP OECD projections [link](https://data.ece.iiasa.ac.at/ssp/#/about), release 3.0.1 (March 2024)) until 2100. The scenarios are extended until 2150 using a bezier curve method that assumes that the slope in 2100 is flattened by half by 2150. For countries lacking projection data, the last historical data point is used in all future years. For more details on the harmonization, see Koch and Leimbach 2023 ([link](https://doi.org/10.1016/j.ecolecon.2023.107751)).
## Population

The SSP GDP scenarios are the product of the GDP per capita and population scenarios.
### SSPs

### SDPs
The SSP population scenarios are constructed using:

The SDPs are all based off of SSP1, with different harmonization functions for the different SDPs. (Reference needed.) The SDP GDP scenarios are the product of the GDP per capita and population scenarios.
- WDI data ([link](https://databank.worldbank.org/source/world-development-indicators)) from 1960 to 2022 (missing country data filled in with UN_PopDiv data ([link](https://population.un.org/wpp/), 2022 revision) and MI data ([link](https://doi.org/10.5281/zenodo.4421504))),

## Population scenarios
- growth rates from the World Bank's Population and Projections database ([link](https://databank.worldbank.org/source/population-estimates-and-projections#)) until 2029, and

### SSPs
- growth rates from from the SSP population projections (release 3.0.1 (March 2024) [link](https://data.ece.iiasa.ac.at/ssp/#/about) and [link](https://doi.org/10.5281/zenodo.10618931)), filled in with UN_PopDiv data ([link](https://population.un.org/wpp/), 2022 revision)) until 2100.

The SSP population scenarios are constructed using past WDI data ([link](https://databank.worldbank.org/source/world-development-indicators)) from 1960 to 2022 (missing country data filled in with UN_PopDiv data ([link](https://population.un.org/wpp/), 2022 revision)) and MI data ([link](https://doi.org/10.5281/zenodo.4421504))), growth rates from the World Bank's Population and Projections database ([link](https://databank.worldbank.org/source/population-estimates-and-projections#)) until 2029, and growth rates from from the SSP population projections (release 3.0.1 (March 2024) [link](https://data.ece.iiasa.ac.at/ssp/#/about) and [link](https://doi.org/10.5281/zenodo.10618931)), filled in with UN_PopDiv data ([link](https://population.un.org/wpp/), 2022 revision)) until 2100. The scenarios are extended until 2150 using a bezier curve method that assumes that the slope in 2100 is flattened by half by 2150. For countries lacking projection data, the last historical data point is used in all future years. For more details on the harmonization, see Koch and Leimbach 2023 ([link](https://doi.org/10.1016/j.ecolecon.2023.107751)).
The scenarios are extended until 2150 using a bezier curve method that assumes that the slope in 2100 is flattened by half by 2150. For countries lacking projection data, the last historical data point is used in all future years. For more details on the harmonization, see Koch and Leimbach 2023 ([link](https://doi.org/10.1016/j.ecolecon.2023.107751)).

### SDPs

The SDP scenarios are all equal to the SSP1 scenario.

## Labour scenarios
## Labour

### SSPs

Expand All @@ -88,12 +73,47 @@ The SSPs labour scenarios are constructed using past WDI data ([link](https://da

The SDP scenarios are all equal to the SSP1 scenario.

## Urban population share scenarios
## Urban population share

### SSPs

The SSPs urban population share scenarios are constructed using past WDI data starting in 1960 ([link](https://databank.worldbank.org/source/world-development-indicators)), and SSP urban population share projections (2018 Release [link](https://data.ece.iiasa.ac.at/ssp/#/about)). The harmonization uses the past levels, and future growth rates.

### SDPs

The SDP, SDP_EI, and SDP_MC scenarios are all equal to the SSP1 scenario. The SDP_RC is equal to the SSP3 for OECD countries, and SSP2 for non-OECD countries.
The SDP, SDP_EI, and SDP_MC scenarios are all equal to the SSP1 scenario. The SDP_RC is equal to the SSP3 for OECD countries, and SSP2 for non-OECD countries.



# Available Scenarios

The tool function `toolGetScenarioDefinition()` can be used to see what driver/scenario options are available.

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup, echo=FALSE, message=FALSE}
library(mrdrivers) # nolint
library(magrittr) # nolint
```

```{r}
toolGetScenarioDefinition() %>% print(n = 200)
```

# User Defined Scenarios

The user can create custom scenarios by creating a tibble called "mrdivers_scenarios" in the global environment, and filling it with the desired scenario definitions. The structure of the "mrdivers_scenarios" object should be identical to that of the return object of `toolGetScenarioDefinition()`, and the scenario building blocks have to be available. For example, say the user wanted to create SSP scenarios, but without using the Missing Islands data-set. The following command executed in the global environment would make the "nomi" (no-missing islands) scenario available.

```{r}
mrdrivers_scenarios <- tibble::tribble( # nolint
~driver, ~scenario, ~pastData, ~futureData, ~harmonization,
"GDPpc", "nomi", "WDI", "SSPs", "GDPpcSSPs",
"Population", "nomi", "WDI", "SSPs", "PopSSPs",
"GDP", "nomi", "-", "-", "GDPpcWithPop"
)
```
Loading