toolCubicFunctionAggregate: toolCubicFunctionAggregate

View source: R/toolCubicFunctionAggregate.R

toolCubicFunctionAggregateR Documentation

toolCubicFunctionAggregate

Description

Estimates the function that represents the sum of cubic function inverses (sum in the x-axis)

Usage

toolCubicFunctionAggregate(
  x,
  rel = NULL,
  xLowerBound = 0,
  xUpperBound = 100,
  returnMagpie = TRUE,
  returnCoeff = TRUE,
  returnChart = FALSE,
  returnSample = FALSE,
  numberOfSamples = 1000,
  unirootLowerBound = -10,
  unirootUpperBound = 1e+100,
  colourPallete = FALSE,
  label = list(x = "x", y = "y", legend = "legend"),
  steepCurve = list()
)

Arguments

x

magclass object that should be aggregated or data frame with coefficients as columns.

rel

relation matrix containing a region mapping. A mapping object should contain 2 columns in which each element of x is mapped to the category it should belong to after (dis-)aggregation

xLowerBound

numeric. Lower bound for x sampling (default=0).

xUpperBound

numeric. Upper bound for x sampling (default=100).

returnMagpie

boolean. if true, the function will return a single data table with all the countries in MagPie format. returnChart and returnSample are set to FALSE automatically if this option is active (default=TRUE).

returnCoeff

boolean. Return estimated coefficients (default=TRUE).

returnChart

boolean. Return chart (default=FALSE).

returnSample

boolean. Return samples used on estimation (default=FALSE).

numberOfSamples

numeric. NUmber of y-axis samples used on estimation (default=1e3).

unirootLowerBound

numeric. Lower bound to search for inverse solution in the initial bounds (default = -10).

unirootUpperBound

numeric. Upper bound to search for inverse solution in the initial bounds (default = 1e100).

colourPallete

vector. colour pallete to use on chart (default=FALSE).

label

list. List of chart labels (default=list(x = "x", y = "y", legend = "legend")).

steepCurve

list. List with coefficients for a very "vertical" function for the case with all countries with upper bound zero in an specific region aggregation (default= empty list, list()).

Details

Use case: aggregate country cubic cost functions to a single function that represents the entire region.

input: coefficients of the n-th country level cubic cost function.

Description of the problem: the aggregation of functions that represent unit costs, or prices in the y-axis, and quantities in the x-axis require operations with the inverse of the original functions. As complex functions present analytically challenging inverse function derivations, we adopt a sampling method to derive the function that corresponds to the sum of cubic function inverses.

Further extensions: the R function can be extended to support more complex curve estimations (beyonf third degree), whenever the mathematical function have a well defined inverse function in the selected boundaries.

Value

return: returns a list of magpie objects containing the coefficients for the aggregate function. If returnMagpie is FALSE, returns a list containing the coefficients for the aggregate function (returnCoeff=TRUE), charts (returnChart=FALSE) and/or samples used in the estimation (returnSample=FALSE).

Author(s)

Renato Rodrigues

See Also

toolCubicFunctionDisaggregate

Examples


# Example
# data
EUR <- setNames(data.frame(30,50,0.123432,2),c("c1","c2","c3","c4"))
NEU <- setNames(data.frame(30,50,1.650330,2),c("c1","c2","c3","c4"))
df <- rbind(EUR,NEU)
row.names(df) <- c("EUR","NEU")
# maxExtraction (upper limit for function estimation)
maxExtraction <- 23
# output
output <- toolCubicFunctionAggregate(df,xUpperBound=maxExtraction,
 returnMagpie=FALSE,returnChart=TRUE,returnSample=TRUE,
 label=list(x="Cumulated Extraction", y="Cost", legend="Region Fuel Functions"))
output$coeff
output$chart

pik-piam/mrremind documentation built on May 1, 2024, 2:12 a.m.