Skip to content

Commit

Permalink
fix calcGDPpcPast calls after mrdrivers update
Browse files Browse the repository at this point in the history
  • Loading branch information
Debbora Leip committed Nov 7, 2024
1 parent e8949a8 commit cdedac9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '1422201'
ValidationKey: '1442448'
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: 'mrfactors: MADRaT based package on factor inputs'
version: 0.7.1
date-released: '2024-11-04'
version: 0.7.2
date-released: '2024-11-07'
abstract: This package provides functions for MAgPIE input data on factor inputs to
agricultural production (with a focus on capital and labor).
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrfactors
Title: MADRaT based package on factor inputs
Version: 0.7.1
Date: 2024-11-04
Version: 0.7.2
Date: 2024-11-07
Authors@R:
c(person("Debbora", "Leip", , "leip@pik-potsdam.de", role = c("aut", "cre")),
person("Edna", "Molina Bacca", role = "aut"))
Expand Down
2 changes: 1 addition & 1 deletion R/calcAgCapLabourShare.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ calcAgCapLabourShare <- function(fillWithRegression = TRUE, projection = FALSE)

regCoeff <- calcOutput("RegFactorShare", aggregate = FALSE)

# calculate GDPpc [USD2017MER] for regression
# calculate GDPpc [USD2017PPP] for regression
gdp <- calcOutput("GDPpc", naming = "scenario", unit = "constant 2017 Int$PPP", aggregate = FALSE)
if (!isFALSE(projection)) {
years <- setdiff(getItems(gdp, dim = 2), paste0("y", seq(2105, 2150, 5)))
Expand Down
2 changes: 1 addition & 1 deletion R/calcAgEmplILO.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ calcAgEmplILO <- function(subsectors = TRUE, inclFish = FALSE, inclForest = FALS
subtype <- ifelse(dataVersionILO == "", "AgEmplShare", paste("AgEmplShare", dataVersionILO, sep = "_"))
regCoeff <- readSource("RegressionsILO", subtype)

gdpPPPpc <- calcOutput("GDPpcPast", unit = "constant 2017 Int$PPP", aggregate = FALSE)
gdpPPPpc <- calcOutput("GDPpcPast", aggregate = FALSE) # in constant 2017 Int$PPP

estShare <- (regCoeff[, , "slope", drop = TRUE] * log10(gdpPPPpc) + regCoeff[, , "intercept", drop = TRUE]) ** 2
const <- (regCoeff[, , "slope"] * log10(regCoeff[, , "threshold"]) + regCoeff[, , "intercept"]) ** 2
Expand Down
13 changes: 8 additions & 5 deletions R/calcRegressionsILO.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ calcRegressionsILO <- function(subtype = "AgEmplShare", dataVersionILO = "Aug24"
if (subtype == "AgEmplShare") {# Regression to fill missing countries in ILO ag. employment data set

cat(paste0("Note: You are recalculating this regression. If this should be the new default regression you",
" need to manually save the resulting regression coefficients in the source folder."))
" need to manually save the resulting regression coefficients in the source folder."))
cat(paste0("Note: In case underlying data changed (agricultural employment from ILO, historic population,",
" or GDP pc PPP) you should double check the resulting regression."))
description <- paste0("Regression coeffcients for sqrt(ag. empl. share) ~ log(GDP pc PPP, base = 10) ",
Expand All @@ -73,8 +73,8 @@ calcRegressionsILO <- function(subtype = "AgEmplShare", dataVersionILO = "Aug24"
share <- iloEmpl[, getYears(pop), "Total", drop = TRUE] / pop[, , , drop = TRUE]
getNames(share) <- "share_empl_ag"

# GDP per capita as independent variable (updated currency baseyear since Aug 24)
gdpPc <- calcOutput("GDPpcPast", unit = "constant 2017 Int$PPP", aggregate = FALSE)
# GDP per capita as independent variable (updated currency baseyear since Aug 24, now in constant 2017 Int$PPP)
gdpPc <- calcOutput("GDPpcPast", aggregate = FALSE)

years <- intersect(getYears(share), getYears(gdpPc))
gdpPc <- gdpPc[, years, ]
Expand Down Expand Up @@ -119,7 +119,7 @@ calcRegressionsILO <- function(subtype = "AgEmplShare", dataVersionILO = "Aug24"

cat(paste0("Note: You are recalculating this regression. If this should be the new default regression you",
" need to manually save the resulting regression coefficients in the source folder."))

## HOURLY LABOR COSTS DATA FROM ILO

# original hourly labor costs dataset (ILO data + data for India + data for China)
Expand All @@ -128,7 +128,10 @@ calcRegressionsILO <- function(subtype = "AgEmplShare", dataVersionILO = "Aug24"
hourlyLaborCosts[hourlyLaborCosts == 0] <- NA

## GDP PER CAPITA IN US$MER AS DEPENDENT VARIABLE (updated currency baseyear since Aug 24)
gdpPcMER <- calcOutput("GDPpcPast", unit = "constant 2017 US$MER", aggregate = FALSE)
gdpPcMER <- GDPuc::toolConvertGDP(calcOutput("GDPpcPast", aggregate = FALSE),
unit_in = "constant 2017 Int$PPP",
unit_out = "constant 2017 US$MER",
replace_NAs = c("with_USA"))

## combining data
years <- intersect(getItems(hourlyLaborCosts, dim = 2), getItems(gdpPcMER, dim = 2))
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MADRaT based package on factor inputs

R package **mrfactors**, version **0.7.1**
R package **mrfactors**, version **0.7.2**

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

Expand Down Expand Up @@ -38,7 +38,7 @@ In case of questions / problems please contact Debbora Leip <leip@pik-potsdam.de

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

Leip D, Molina Bacca E (2024). _mrfactors: MADRaT based package on factor inputs_. R package version 0.7.1, <URL: https://github.com/pik-piam/mrfactors>.
Leip D, Molina Bacca E (2024). _mrfactors: MADRaT based package on factor inputs_. R package version 0.7.2, <https://github.com/pik-piam/mrfactors>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {mrfactors: MADRaT based package on factor inputs},
author = {Debbora Leip and Edna {Molina Bacca}},
year = {2024},
note = {R package version 0.7.1},
note = {R package version 0.7.2},
url = {https://github.com/pik-piam/mrfactors},
}
```

0 comments on commit cdedac9

Please sign in to comment.