Package 'mrfactors'

Title: MADRaT based package on factor inputs
Description: This package provides functions for MAgPIE input data on factor inputs to agricultural production (with a focus on capital and labor).
Authors: Debbora Leip [aut, cre], Edna Molina Bacca [aut]
Maintainer: Debbora Leip <[email protected]>
License: LGPL-3 | file LICENSE
Version: 0.7.3
Built: 2024-12-04 14:23:13 UTC
Source: https://github.com/pik-piam/mrfactors

Help Index


MADRaT based package on factor inputs

Description

This package provides functions for MAgPIE input data on factor inputs to agricultural production (with a focus on capital and labor).

Author(s)

Maintainer: Debbora Leip <[email protected]>

See Also

Useful links:


calcAgCapLabourShare

Description

This function calculates historical capital shares (Capital + Labour) of the factor requirements using USDA

Usage

calcAgCapLabourShare(fillWithRegression = TRUE, projection = FALSE)

Arguments

fillWithRegression

boolean: should missing values be filled based on a regression between capital share and GDPpcPPP (calibrated to countries)

projection

either FALSE or SSP on which projections should be based. Only relevant if fillWithRegression is TRUE.

Value

MAgPIE object

Author(s)

Edna J. Molina Bacca, Debbora Leip

See Also

[calcAgCapLabourShare()]

Examples

## Not run: 
calcOutput("calcAgCapLabourShare")

## End(Not run)

calcAgEmplILO

Description

calculates complete dataset of number of people employed in agriculture, forestry and fishery based on ILO modelles dataset and GDPpcPPP05 for regression

Usage

calcAgEmplILO(
  subsectors = TRUE,
  inclFish = FALSE,
  inclForest = FALSE,
  dataVersionILO = "Aug24"
)

Arguments

subsectors

boolean: should overall values be split into the sub-sectors agriculture, forestry and fishery based on their relative share of people employed, and agriculture further split into crops and livestock based on VoP

inclFish

boolean: should employment in fisheries be included?

inclForest

boolean: should emplyoment in forestry be included?

dataVersionILO

which version of the ILO input data to use. "" for the oldest version and old regression, or "monthYear" (e.g. "Aug24") for newer data

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("AgEmplILO")

## End(Not run)

calcFacReq

Description

This function calculates factor requirement costs (constant 2017 US$MER/tDM) on regional level, based FAO databases

Usage

calcFacReq(splitSectors = FALSE)

Arguments

splitSectors

if TRUE requirements for labor and capital will be reported separately

Value

MAgPIE object

Author(s)

Debbora Leip

See Also

[calcOutput()],[calcFactorIntensity()]

Examples

## Not run: 
calcOutput("calcFacReq")

## End(Not run)

calcFacReqGLO

Description

This function calculates 2005 global factor requirement costs (05USDMER/tDM) using FAO databases

Usage

calcFacReqGLO()

Value

MAgPIE object

Author(s)

Edna J. Molina Bacca

See Also

[calcOutput()],[calcFactorIntensity()]

Examples

## Not run: 
calcOutput("calcFacReqGLO")

## End(Not run)

calcFactorCosts

Description

combines factor costs for crop and livestock production in mio. US$MER05

Usage

calcFactorCosts(
  datasource = "USDA",
  otherLivst = FALSE,
  subsectors = FALSE,
  unit = "constant 2017 US$MER"
)

Arguments

datasource

only source available is "USDA" (calculates factor costs by applying factor cost share from USDA to VoP from FAO)

otherLivst

boolean: should FAO livestock categories that can't be matched to MAgPIE categories (i.e. beeswax, wool, silkworms, and honey) be reported as "livst_other"?

subsectors

boolean: should output be aggregated or reported by crop and livestock subsectors?

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("FactorCosts")

## End(Not run)

calcFactorCostsCrops

Description

calculates factor costs for crop production in mio. US$MER05

Usage

calcFactorCostsCrops(datasource = "USDA", unit = "constant 2017 US$MER")

Arguments

datasource

only source available is "USDA" (calculates factor costs by applying factor cost share from USDA to VoP from FAO)

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("FactorCostsCrops")

## End(Not run)

calcFactorCostsLivst

Description

calculates factor costs for livestock production in mio. US$MER05

Usage

calcFactorCostsLivst(
  datasource = "USDA",
  otherLivst = FALSE,
  inclFish = FALSE,
  unit = "constant 2017 US$MER"
)

Arguments

datasource

only source available is "USDA" (calculates factor costs by applying factor cost share from USDA to VoP from FAO)

otherLivst

boolean: should FAO livestock categories that can't be matched to MAgPIE categories (i.e. beeswax, wool, silkworms, and honey) be reported as "livst_other"?

inclFish

boolean: should fish factor costs be included?

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("FactorCostsLivst")

## End(Not run)

calcFactorIntensity

Description

Calculates factor intensity in crop production for labour and/or capital from USDA (Inputs share) and FAO (Value of Production)in constant 2017 US$MER per ton. Capital intensity and requirements can also be calculated from FAO's CapitalStock database.

Usage

calcFactorIntensity(
  output = "intensities",
  method = "USDA",
  unit = "constant 2017 US$MER"
)

Arguments

output

needed outputs. It can be either "intensities" (Capital/Labour factor intensities), "requirements" (Capital Stock requirements per ton), and "CapitalShare" for "USDA" method. For the "CapitalStock" method only "intensities" and "requirements" outputs supported.

method

"USDA" or "CapitalStock"

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

magpie object of the factor requirements intensity or factor intensity in USD/tDM per crop, or capital share fraction.

Author(s)

Edna J. Molina Bacca

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("FactorIntensity")

## End(Not run)

calcFractionInputsUSDA

Description

Calculates the factor factor shares for crop or livestock production from USDA'S Inputs shares.

Usage

calcFractionInputsUSDA(
  products = "kcr",
  keepConstantExtrapolation = TRUE,
  interpolate = TRUE
)

Arguments

products

either "kcr" for crops, or "kli" for livestock

keepConstantExtrapolation

boolean: should constant extrapolation from Fuglie et al. be kept?

interpolate

boolean: should the data be interpolated to the middle of the decade?

Value

magpie object of the shares of the factor requirements in agriculture (capital, labor, materials, land).

Author(s)

Edna J. Molina Bacca, Debbora Leip

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("FractionInputsUSDA")

## End(Not run)

calcHourlyLaborCosts

Description

calculates dataset of hourly labor costs per employee in agriculture

Usage

calcHourlyLaborCosts(
  datasource = "USDA_FAO",
  dataVersionILO = "Aug24",
  sector = "agriculture",
  fillWithRegression = TRUE,
  calibYear = 2010,
  cutAfterCalibYear = TRUE,
  projection = FALSE
)

Arguments

datasource

either raw data from "ILO" (agriculture+forestry+fishery) or data calculated based on total labor costs from "USDA_FAO" (crop+livestock production).

dataVersionILO

Which version of ILO data to use (for hourly labor costs if source is ILO, for ag empl. if source is USDA_FAO). "" for the oldest version, or "monthYear" (e.g. "Aug24") for a newer version)

sector

should average hourly labor costs be reported ("agriculture"), or hourly labor costs specific to either "crops" or "livestock" production. For ILO only the aggregate hourly labor costs are available.

fillWithRegression

boolean: should missing values be filled based on a regression between ILO hourly labor costs and GDPpcMER (calibrated to countries)

calibYear

in case of fillWithRegression being TRUE, data after this year will be ignored and calculated using the regression (calibrated for each year to calibYear, or the most recent year with data before calibYear). NULL if all data should be used for calibration

cutAfterCalibYear

boolean, only relevant if fillWithRegression is TRUE. If cutAfterCalibYear is TRUE, raw data after the calib year is overwritten by regression results (necessary for consistency with calculation within MAgPIE). If FALSE, raw data is kept and only gaps are filled with regression

projection

either FALSE or SSP on which projections should be based. Only relevant if fillWithRegression is TRUE.

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("HourlyLaborCosts")

## End(Not run)

calcIFPRIsubsidy

Description

Adds non-allocated subsidies to crop subsidies (as most subsidies are linked to land area), and excludes NRP subsidies (as those are border measures, which are already reflected in ag. prices)

Usage

calcIFPRIsubsidy(fillGaps = TRUE)

Arguments

fillGaps

boolean, should gaps in the dataset be filled using interpolation?

Value

magpie object. in mio. USD

Author(s)

Debbora Leip

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("IFPRIsubsidy")

## End(Not run)

calcLaborCosts

Description

calculates total labor costs in mio. US$MER05 (coverage depends on source: crop, livestock and fish production for USDA, and additionally forestry for GTAP and ILO)

Usage

calcLaborCosts(
  datasource = "ILO",
  dataVersionILO = "Aug24",
  subsectors = TRUE,
  inclFish = FALSE,
  inclForest = FALSE,
  otherLivst = TRUE,
  gtapVar = "NVFA",
  addSubsidies = FALSE
)

Arguments

datasource

data source on which the labor costs should be based. Available are ILO, USDA (which also uses data on VoP from FAO), and GTAP.

dataVersionILO

If source is ILO, the version can be chosen. "" for the oldest version, or "monthYear" (e.g. "Aug24") for a newer version)

subsectors

boolean: should output be aggregated or split into available subsectors (crops, livst, forestry, fishery)

inclFish

boolean: should fish labor costs be included?

inclForest

boolean: should forestry labor costs be included (only available for ILO and GTAP)?

otherLivst

boolean: should other_livst category (i.e. beeswax, wool, silkworms, and honey) be included in livestock (only relevant for datasource USDA)?

gtapVar

variable name to use from GTAP (only relevant if source is "GTAP")

addSubsidies

boolean: should subsidy data (from IFPRI) should be added to VoP before applying USDA cost shares (only relevant if datasource is "USDA")

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("LaborCosts", datasource = "ILO")

## End(Not run)

calcNonMAgPIEFactorCosts

Description

Calculates factor costs that should affect agricultural employment but are not included in MAgPIE factor costs

Usage

calcNonMAgPIEFactorCosts(
  subtype = "subsidies",
  aggSubsidies = FALSE,
  extrapolate = TRUE
)

Arguments

subtype

either factor cost share of "subsidies" (which don't enter MAgPIE labor costs as they should not affect prices), or of "missingVoP" (which refers to livestock VoP that can't be mapped to MAgPIE livestock categories, i.e. wool, beeswax, honey, silk-worms)

aggSubsidies

boolean: if subtype is "subsidies", should crop and livestock subsidies be reported separately or as aggregate?

extrapolate

boolean: should values be extrapolate (by keeping constant) until 2150?

Value

magpie object. in mio. USD

Author(s)

Debbora Leip

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("NonMAgPIEFactorCosts", subtype = "subsidies")

## End(Not run)

calcPricesProducer

Description

producer prices for agricultural products. 05USDMER/tDM prices from FAO, no currency conversion

Usage

calcPricesProducer(
  products = "kcr",
  calculation = "VoP",
  weighting = "production"
)

Arguments

products

either "kcr" or "kcl"

calculation

type of calculation "FAO" (directly reads the data), "VoP" calculates as VoP/Production, only "FAO" available for "kli" products.

weighting

either "production" (default) or "consumption" based weighting

Value

magpie object. prices in year specific annual

Author(s)

Edna J. Molina Bacca

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("PricesProducer")

## End(Not run)

calcProductionCosts

Description

calculates agricultural production costs (split into different cost categories)

Usage

calcProductionCosts(datasource = "Vittis", unit = "constant 2017 US$MER")

Arguments

datasource

Datasource of production costs, currently only "Vittis"

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("ProductionCosts", source = "Vittis")

## End(Not run)

calcRegFactorShare

Description

This function calculates the regression parameters (a and b) for the function Share=a*log10(GDP)+b Where share is the adjusted share between capital and labour.

Usage

calcRegFactorShare(datasource = "USDA", caseStudies = "CountryCaseStudies")

Arguments

datasource

Only USDA available

caseStudies

The case studies to be used for the regression (either CountryCaseStudies or CaseStudiesDirectMapping). Default is CountryCaseStudies, as including regional case studies weakens the direct link to GDP per capita (and results in a regression with non-normally distributed residuals).

Value

MAgPIE object at global level with slope and intersect as items

Author(s)

Debbora Leip, Edna J. Molina Bacca

See Also

[calcOutput()],[calcFactorIntensity()]

Examples

## Not run: 
calcOutput("calcRegFactorShare")

## End(Not run)

regressionsILO

Description

Calculates regression coefficients used by calc functions for ILO data sets

Usage

calcRegressionsILO(
  subtype = "AgEmplShare",
  dataVersionILO = "Aug24",
  thresholdWage = 0.1,
  forceWageIntercept = TRUE,
  wageRegrType = NULL,
  recalculate = FALSE
)

Arguments

subtype

specifies the regression type: "AgEmplShare" for a regression between the square root of the share of people employed in agriculture (out of total population) and the log (base 10) of GDP pc PPP05. "HourlyLaborCosts" for a regression between mean nominal hourly labor cost per employee in agriculture and GDP pc MER05.

dataVersionILO

which version of the ILO input data and regression to use. "" for the oldest version and old regression, or "monthYear" (e.g. "Aug24") for newer data with the new regression type

thresholdWage

only relevant for linear hourly labor cost regression: for low GDP pc MER, the regression between hourly labor costs and GDP pc MER can lead to unreasonably low or even negative hourly labor costs. Therefore, we set all hourly labor costs below this threshold to the threshold.

forceWageIntercept

only relevant for linear hourly labor cost regression: If TRUE, the wage threshold is also used as intercept of the regression. If FALSE, the intercept is determined by the regression

wageRegrType

Only relevant for HourlyLaborCosts regression. If NULL, a linear regression will be used for the oldest data (dataVersionILO: ""), and a loglog regression for all newer data. Can be overwritten by specifically setting wageRegrType to "linear" or "loglog".

recalculate

whether regression should be read from source folder, or recalculated from scratch. Recalculation can lead to new regression coefficients if data changed, and result should always be checked.

Author(s)

Debbora Leip

Examples

## Not run: 
    a <- calcOutput("RegressionsILO", subtype = "HourlyLaborCosts")

## End(Not run)

calcVoPAFF

Description

Calculates the overall value of production of the agriculture, forestry and fisheries sectors. Forestry and Fisheries are calculated from exports values.

Usage

calcVoPAFF(unit = "constant 2017 US$MER")

Arguments

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

magpie object. in mio. USD

Author(s)

Edna J. Molina Bacca, Debbora Leip

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("VoPAFF")

## End(Not run)

calcVoPcrops

Description

Calculates the value of production of individual production items or its fraction compared to overall Value of Production (Agriculture, Fish, Forestry).

Usage

calcVoPcrops(fillGaps = TRUE, unit = "constant 2017 US$MER")

Arguments

fillGaps

boolean: should gaps be filled using production * prices (where production data is available)?

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

magpie object. in mio. USD or fraction

Author(s)

Edna J. Molina Bacca, Debbora Leip

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("VoPcrops")

## End(Not run)

calcVoPlivst

Description

Calculates the value of production of individual livestock categories

Usage

calcVoPlivst(other = FALSE, fillGaps = TRUE, unit = "constant 2017 US$MER")

Arguments

other

boolean: should FAO livestock categories that can't be matched to MAgPIE categories (i.e. beeswax, wool, silkworms, and honey) be reported as "livst_other"?

fillGaps

boolean: should gaps be filled using production * prices (where production data is available)?

unit

output currency unit based on the toolConvertGDP function from the GDPuc library

Value

magpie object

Author(s)

Debbora Leip

See Also

[calcOutput()]

Examples

## Not run: 
a <- calcOutput("VoPlivst")

## End(Not run)

calcWeeklyHoursILO

Description

calculates complete dataset of mean weekly hours worked by people employed in agriculture, forestry and fishery based on ILO dataset

Usage

calcWeeklyHoursILO(projections = FALSE, dataVersionILO = "Aug24")

Arguments

projections

boolean, should weekly hours be projected (by keeping constant) up to 2150?

dataVersionILO

which version of the ILO input data to use. "" for the oldest version and old regression, or "monthYear" (e.g. "Aug24") for newer data

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("WeeklyHoursILO")

## End(Not run)

convertIFPRIsubsidy

Description

disaggregates EU subsidies for crops and livestock from IFPRI table to country level

Usage

convertIFPRIsubsidy(x)

Arguments

x

magpie object provided by the read function

Value

magpie object of agricultural subsidies

Author(s)

Debbora Leip

Examples

## Not run: 
a <- readSource("IFPRIsubsidy", convert = TRUE)

## End(Not run)

convertILOSTAT

Description

transforms currencies where applicable, and fills missing countries in ILOSTAT data with 0

Usage

convertILOSTAT(x)

Arguments

x

unconverted magpie object from read-script

Value

Data as MAgPIE object with common country list

Author(s)

Debbora Leip

Examples

## Not run: 
a <- readSource("ILOSTAT", subtype = "EmplByActivityModelled", convert = TRUE)

## End(Not run)

convertVittis

Description

Aggregate production costs from Vittis dataset to MAgPIE crop categories and change unit from USD PPP 2000 to USD MER 2017.

Usage

convertVittis(x)

Arguments

x

MAgPIE object to be converted

Value

A MAgPIE object containing national-scale costs of production for 10 crops, disaggregated in 9 distinct cost elements

Author(s)

Debbora Leip


correctTFPUSDA

Description

Remove values that are just constant extrpolation

Usage

correctTFPUSDA(x)

Arguments

x

magpie object provided by the read function

Value

corrected mapie object on national-scale costs of production for 10 crops, disaggregated in 9 distinct cost elements

Author(s)

Debbora Leip

See Also

[readTFPUSDA()]


correctVittis

Description

Correct inconsistencies in crop naming in the Vittis dataset

Usage

correctVittis(x)

Arguments

x

magpie object provided by the read function

Value

corrected mapie object on national-scale costs of production for 10 crops, disaggregated in 9 distinct cost elements

Author(s)

Debbora Leip

See Also

[readVittis()]


downloadILOSTAT

Description

Download data from ILOSTAT

Usage

downloadILOSTAT(subtype)

Arguments

subtype

Type of ILOSTAT data that should be downloaded, version specified by suffic "_MonthYear" (month and year of download)

Value

metadata entry

Author(s)

Debbora Leip

Examples

## Not run: 
  downloadSource("ILOSTAT", "EmplByActivityModelled")

## End(Not run)

downloadTFPUSDA

Description

Downloads data of input shares based on a TFP assessment from USDA.

Usage

downloadTFPUSDA()

Value

raw TFP file from USDA

Author(s)

Edna J. Molina Bacca

See Also

[downloadSource()]


readHourlyLaborCostsChina

Description

Read in data on hourly labor costs in agriculture for China.

Usage

readHourlyLaborCostsChina()

Value

data as MAgPIE object

Author(s)

Debbora Leip

Examples

## Not run: 
readSource("HourlyLaborCostsChina")

## End(Not run)

readIFPRIsubsidy

Description

read subsidies for crops and livestock (and non-allocated) from IFPRI table

Usage

readIFPRIsubsidy()

Value

magpie object of agricultural subsidies

Author(s)

Debbora Leip

Examples

## Not run: 
  readSource("IFPRIsubsidy")

## End(Not run)

readILOSTAT

Description

Read in ILOSTAT data that has been downloaded from the ILOSTAT website

Usage

readILOSTAT(subtype)

Arguments

subtype

Type of ILOSTAT data that should be downloaded, version specified by suffic "_MonthYear" (month and year of download)

  • 'EmplByActivityModelled': "Employment by sex and economic activity – ILO modelled estimates, Nov. 2020 (thousands)"

  • 'WeeklyHoursByActivity': "Mean weekly hours actually worked per employed person by sex and economic activity"

  • 'HourlyLaborCostsByActivity': "Mean nominal hourly labour cost per employee by economic activity"

  • 'EmplByISIC2': "Employment by sex and economic activity - ISIC level 2 (thousands) | Annual"

  • 'EmplByActivityMonthly': "Employment by sex and economic activity (thousands) | Monthly"

  • 'EmplByActivityMonthlyAdj': "Employment by sex and economic activity, seasonally adjusted series (thousands) | Monthly"

  • 'EmplByActivityAndStatus': "Employment by sex, status in employment and economic activity (thousands) | Annual"

  • 'WeeklyHoursByActivityMonthly': "Mean weekly hours actually worked per employee by sex and economic activity | Monthly"

  • 'WeeklyHoursByISIC2': "Mean weekly hours actually worked per employed person by sex and economic activity - ISIC level 2 | Annual"

  • 'WeeklyHoursEmployeesByISIC2': "Mean weekly hours actually worked per employee by sex and economic activity - ISIC level 2 | Annual"

  • 'LaborIncomeShareGDPModelled': "Labour income share as a percent of GDP – ILO modelled estimates, July 2019 (

  • 'OutputPerWorkerModelled': "Output per worker (GDP constant 2010 US $) – ILO modelled estimates, Nov. 2020 | Annual"

Value

ILOSTAT data as MAgPIE object

Author(s)

Debbora Leip

Examples

## Not run: 
  readSource("ILOSTAT", "EmplByActivityModelled")

## End(Not run)

readRegressionsILO

Description

Read regression coefficients which are used to fill missing values of ILO datasets

Usage

readRegressionsILO(subtype = "AgEmplShare")

Arguments

subtype

Type of ILOSTAT data for which regression coefficients should be read

  • 'AgEmplShare': regression coefficients for sqr(ag empl share) ~ log(GDP pc PPP)

  • 'HourlyLaborCosts': regression coefficients for hourly labor costs ~ GDP pc MER (old version) or log(hourly labor costs) ~ log(GDP pc MER) (new version)

The version of regression and underlying data can be chosen by adding a suffix to the subtype, "" for the oldest version, or "_monthYear" (e.g. "_Aug24") for newer version

Value

regression coefficients as MAgPIE object

Author(s)

Debbora Leip

Examples

## Not run: 
  readSource("RegressionsILO", "AgEmpl")

## End(Not run)

readTFPUSDA

Description

Reads the input shares from USDA's Agricultural total factor productivity growth indices assessment.

Usage

readTFPUSDA()

Value

magpie object with fractions of different input factors in the overall production value

Author(s)

Edna J. Molina Bacca

See Also

[readSource()]


readVittis

Description

Read-in cost data from Vittis dataset.

Usage

readVittis()

Value

National-scale costs of production for 10 crops, disaggregated in 9 distinct cost elements

Author(s)

Debbora Leip

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("Vittis")

## End(Not run)