Skip to contents

scenario_aroc() uses the annual rate of change (AROC) in different cases to calculate the values of the scenario:

Usage

scenario_aroc(
  df,
  value_col = "value",
  start_year = 2018,
  end_year = 2025,
  baseline_year = 2018,
  target_year = end_year,
  target_value = NULL,
  percent_change = NULL,
  aroc_type = c("target", "latest", "percent_change"),
  scenario_name = glue::glue("aroc_{aroc_type}"),
  scenario_col = "scenario",
  limit_aroc_direction = NULL,
  limit_aroc_value = 0,
  trim = TRUE,
  small_is_best = FALSE,
  keep_better_values = TRUE,
  start_year_trim = start_year,
  end_year_trim = end_year,
  upper_limit = 100,
  lower_limit = 0,
  trim_years = TRUE,
  ind_ids = billion_ind_codes("all"),
  default_scenario = "default"
)

Arguments

df

Data frame in long format, where 1 row corresponds to a specific country, year, and indicator.

value_col

Column name of column with indicator values.

start_year

Start year for scenario, defaults to 2018.

end_year

End year for scenario, defaults to 2025

baseline_year

Year from which the scenario is measured. Defaults to start_year

target_year

Year by which the scenario should eventually be achieved. Defaults to end_year

target_value

value to be reached. Used when aroc_type is target. Should be expressed as a percentage point and not a fraction of 100 (e.g. 6% increase = 6, and not 0.06).

percent_change

Numeric with the percent_change. Should be expressed a as percentage point and not a fraction of 100 (e.g. 6% increase = 6, and not 0.06).

aroc_type

String identifying type of AROC. Can be target,latest or percent_change. See details. Defaults to target.

scenario_name

Name of the scenario. Defaults to scenario_percent_change_baseline_year

scenario_col

Column name of column with scenario identifiers. Useful for calculating contributions on data in long format rather than wide format.

limit_aroc_direction

string is identify if positive or negative AROC should be limited by limit_aroc_value. If NULL (default), no limitation will be applied

limit_aroc_value

numeric with values at which the AROC should be limited to. If limit_aroc_direction is positive, will take the maximum between limit_aroc_value and AROC. If negative, it will take the minimum between 0 and AROC. Defaults to 0. Ignored if limit_aroc_direction is NULL (default).

trim

logical to indicate if the data should be trimmed between upper_limit and lower_limit.

small_is_best

Logical to identify if a lower value is better than a higher one (e.g. lower obesity in a positive public health outcome, so obesity rate should have small_is_best = TRUE).

keep_better_values

logical to indicate if "better" values should be kept from value_col if they are present. Follows the direction set in small_is_best. For instance, if small_is_best is TRUE, then value_col lower than col will be kept.

start_year_trim

(integer) year to start trimming from.

end_year_trim

(integer) year to end trimming.

upper_limit

limit at which the indicator should be caped. Can take any of "guess", or any numeric. guess (default) will take 100 as the limit if percent_change is positive, and 0 if negative.

lower_limit

limit at which the indicator should be caped. Can take any of "guess", or 0 to 100. guess (default) will take 0 as the limit if percent_change is positive, and 100 if negative.

trim_years

logical to indicate if years before start_year_trim and after end_year_trim should be removed

ind_ids

Named vector of indicator codes for input indicators to the Billion. Although separate indicator codes can be used than the standard, they must be supplied as a named vector where the names correspond to the output of billion_ind_codes().

default_scenario

name of the default scenario to be used.

Details

  • target: aims at a specific target_value by target_year

  • latest: takes the AROC between baseline_year and the previous year

  • percent_change: applies percent_change for the AROC from baseline_year.

This function is different than scenario_percent_baseline() or scenario_linear_change() as it uses percentage difference and not percentage points difference.

AROC use a general compounded rate of change formula: (Value(year_n) / Value(year_0)) ^ (1 / (year_n - year_0)) - 1

direction_limit_aroc in combination with limit_aroc allows to limit the AROC to a value given a direction. This can be helpful to avoid extreme values if AROC is unknown before being passed to the function.If direction_limit_aroc is positive, the AROC will be the minimum between the calculated AROC and limit_aroc. If negative, it will be the maximum between AROC and