Add an indifference curve to a data frame
add_indifference_curve.Rd
Adds an indifference curve to a data frame of indifference curves to be plotted on a consumption path graph. The indifference curves are accumulated in rows.
Usage
add_indifference_curve(
.DF = NULL,
meta,
graph_type = ReboundTools::graph_types$consumption,
line_name,
qs1_qs0,
Co1_Co0,
qs2_qs0 = NULL,
f_Cs_orig,
sigma,
graph_params = ReboundTools::path_graph_params,
eeu_base_params = ReboundTools::eeu_base_params,
graph_df_colnames = ReboundTools::graph_df_colnames
)
Arguments
- .DF
A data frame that accumulates indifference curves for consumption path graphs. When
NULL
, the default, a new data frame is created and returned. When notNULL
, rows for the curves are added to the bottom of.DF
.- meta
A data frame of metadata for the segment to be added. This metadata data frame provides the left-most columns of the return value.
- graph_type
The graph type for the indifference curve. Default is
ReboundTools::graph_types$consumption
.- line_name
A name for this indifference curve.
- qs1_qs0, Co1_Co0
The (x,y) coordinates of a point on this indifference curve.
- qs2_qs0
A second x value at which a a point on the indifference curve should be calculated. Default is
NULL
.- f_Cs_orig
The ratio of spending on the energy service to the sum of initial spending on the energy service and other goods.
- sigma
The elasticity of substitution between spending on the energy service and spending on other goods.
- graph_params
Parameters that control the appearance of this graph.
- eeu_base_params
- graph_df_colnames
A list of column names to use throughout the package. Default is
ReboundTools::graph_df_colnames
.
Details
The consumption path graph is always indexed, so there is no indexed
argument.
This function finds a reasonable range over which to sweep the qs_qs0
variable
when generating the indifference curve, depending on the value of qs2_qs0
.
When qs2_qs0
is NULL
(the default), the curve is generated over the range
grqph_params$qs_qs0_lower * qs1_qs0
to grqph_params$qs_qs0_upper * qs1_qs0
.
When qs2_qs0
is non-NULL
, the curve is generated over the range
grqph_params$qs_qs0_lower * min(qs1_qs0, qs2_qs0)
to
grqph_params$qs_qs0_upper * max(qs1_qs0, qs2_qs0)
.
Examples
meta <- tibble::tibble(Case = "Test case")
add_indifference_curve(meta = meta, line_name= "Test indifference curve",
qs1_qs0 = 2, Co1_Co0 = 3, f_Cs_orig = 0.0001, sigma = 0.2)
#> # A tibble: 183 × 12
#> Case graph_type line_name colour linewidth linetype qs1_qs0 Co1_Co0
#> <chr> <chr> <chr> <chr> <dbl> <chr> <dbl> <dbl>
#> 1 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 2 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 3 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 4 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 5 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 6 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 7 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 8 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 9 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> 10 Test case Consumption Test indiffe… black 0.5 solid 2 3
#> # ℹ 173 more rows
#> # ℹ 4 more variables: f_Cs_orig <dbl>, sigma <dbl>, x <dbl>, y <dbl>