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_typeistarget. 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,latestorpercent_change. See details. Defaults totarget.- 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_directionispositive, will take the maximum betweenlimit_aroc_valueand AROC. Ifnegative, it will take the minimum between 0 and AROC. Defaults to 0. Ignored iflimit_aroc_directionis NULL (default).- trim
logical to indicate if the data should be trimmed between
upper_limitandlower_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_colif they are present. Follows the direction set insmall_is_best. For instance, if small_is_best is TRUE, thenvalue_collower thancolwill 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 ifpercent_changeis 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 ifpercent_changeis positive, and 100 if negative.- trim_years
logical to indicate if years before
start_year_trimand afterend_year_trimshould 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 specifictarget_valuebytarget_yearlatest: takes the AROC betweenbaseline_yearand the previous yearpercent_change: appliespercent_changefor the AROC frombaseline_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
See also
Basic scenarios
scenario_bau(),
scenario_best_of(),
scenario_linear_change(),
scenario_percent_baseline()