View source: R/scenarios_aroc.R
scenario_aroc | R Documentation |
scenario_aroc()
uses the annual rate of change (AROC) in different cases to
calculate the values of the scenario:
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"
)
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 |
target_year |
Year by which the scenario should eventually be
achieved. Defaults to |
target_value |
value to be reached. Used when |
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 |
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 |
numeric with values at which the AROC should be limited to.
If |
trim |
logical to indicate if the data should be trimmed between
|
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 |
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. |
lower_limit |
limit at which the indicator should be caped.
Can take any of "guess", or 0 to 100. |
trim_years |
logical to indicate if years before |
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
|
default_scenario |
name of the default scenario to be used. |
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
Basic scenarios
scenario_bau()
,
scenario_best_of()
,
scenario_linear_change()
,
scenario_percent_baseline()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.