-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corporate economy for plotting #269
Comments
Ya, so to compare against the portfolio/ targets, we would need to plot either the tfsr or mfsp of the corporate economy, depending on the technology. We would then either normalize the start value of the portfolio, or normalize it all to either 0 or 1. We should discuss this and decide if this should occur in the AKA. It's not a weighting issue, it's an issue of the rate of change. |
yep - agreed. thanks! |
This should occur in |
Somewhat relates to #105 |
Ok so I did a first stab at a reprex to isolate this issue. It's a pretty length reprex, but what I have shown below is as follows. I then run What you will notice is that, in the first plot, the This is because we are calculating moving targets for the scenarios (in relation to the portfolio) and comparing it against a static corporate economy (just normalized). This is what I EXPECT to see given the current methodology, however what I and @georgeharris2deg WANT to see if a methodology in which the corporate economy always lands in place in relation to the scenarios. My proposed solution would be to calculate the tmsr or smsp of the ALD itself, and calculate it in library(r2dii.data)
library(r2dii.match)
library(r2dii.analysis)
library(r2dii.plot.static)
library(tidyverse)
matched1 <- tibble::tribble(
~id_loan, ~loan_size_outstanding, ~loan_size_outstanding_currency, ~loan_size_credit_limit, ~loan_size_credit_limit_currency, ~id_2dii, ~level, ~score, ~sector, ~name_ald, ~sector_ald,
"L1", 1L, "EUR", 1L, "EUR", "UP1", "ultimate_parent", 1L, "power", "slow build out", "power"
)
matched2 <- tibble::tribble(
~id_loan, ~loan_size_outstanding, ~loan_size_outstanding_currency, ~loan_size_credit_limit, ~loan_size_credit_limit_currency, ~id_2dii, ~level, ~score, ~sector, ~name_ald, ~sector_ald,
"L1", 1L, "EUR", 1L, "EUR", "UP1", "ultimate_parent", 1L, "power", "fast build out", "power"
)
ald <- tibble::tribble(
~name_company, ~sector, ~technology, ~year, ~production, ~emission_factor, ~plant_location, ~is_ultimate_owner,
"slow build out", "power", "renewablescap", 2020L, 1000, 1L, "DE", TRUE,
"slow build out", "power", "renewablescap", 2025L, 1100, 1L, "DE", TRUE,
"fast build out", "power", "renewablescap", 2020L, 1000, 1L, "DE", TRUE,
"fast build out", "power", "renewablescap", 2025L, 2000, 1L, "DE", TRUE
)
scenario <- tibble::tribble(
~scenario, ~sector, ~technology, ~region, ~year, ~tmsr, ~smsp, ~scenario_source,
"nps", "power", "renewablescap", "global", 2020L, 1L, 0, "demo_2020",
"nps", "power", "renewablescap", "global", 2025L, 2L, 0.1, "demo_2020",
"sds", "power", "renewablescap", "global", 2020L, 1L, 0, "demo_2020",
"sds", "power", "renewablescap", "global", 2025L, 3L, 0.2, "demo_2020",
"b2ds", "power", "renewablescap", "global", 2020L, 1L, 0, "demo_2020",
"b2ds", "power", "renewablescap", "global", 2025L, 4L, 0.3, "demo_2020"
)
out1 <- target_market_share(
matched1,
ald,
scenario,
region_isos_demo
)
out2 <- target_market_share(
matched2,
ald,
scenario,
region_isos_demo
)
# process data for plotting
plot_out1 <- process_input_data(out1)
plot_out2 <- process_input_data(out2)
out1_trajectory <- prepare_for_trajectory_chart(
plot_out1,
sector_filter = "power",
technology_filter = "renewablescap",
region_filter = "global",
scenario_source_filter = "demo_2020",
value_name = "production",
end_year_filter = 2025,
normalize_to_start_year = TRUE
)
out2_trajectory <- prepare_for_trajectory_chart(
plot_out2,
sector_filter = "power",
technology_filter = "renewablescap",
region_filter = "global",
scenario_source_filter = "demo_2020",
value_name = "production",
end_year_filter = 2025,
normalize_to_start_year = TRUE
)
scenario_specs <- tibble(
scenario = c("b2ds", "sds", "nps", "worse"),
color = c("#9CAB7C", "#FFFFCC", "#FDE291", "#E07B73"),
label = c("B2DS", "SDS", "NPS", "worse")
)
main_line_metric <- tibble(
metric = "projected",
label = "Portfolio"
)
additional_line_metrics <- tibble(
metric = "corporate_economy",
label = "Corporate Economy"
)
plot_trajectory(
out1_trajectory,
scenario_specs_good_to_bad = scenario_specs,
main_line_metric = main_line_metric,
additional_line_metrics = additional_line_metrics
) +
labs(
title = "Production trajectory",
subtitle = "Renewables Capacity technology in the Power, sector",
x = "Year",
y = "Production rate (normalized to 2020)"
)
#> Error in plot_trajectory(out1_trajectory, scenario_specs_good_to_bad = scenario_specs, : non-numeric argument to binary operator plot_trajectory(
out2_trajectory,
scenario_specs_good_to_bad = scenario_specs,
main_line_metric = main_line_metric,
additional_line_metrics = additional_line_metrics
) +
labs(
title = "Production trajectory",
subtitle = "Renewables Capacity technology in the Power, sector",
x = "Year",
y = "Production rate (normalized to 2020)"
)
#> Error in plot_trajectory(out2_trajectory, scenario_specs_good_to_bad = scenario_specs, : non-numeric argument to binary operator Created on 2021-05-19 by the reprex package (v2.0.0) |
I have replaced the "bug" label with an "enhancement" label, as this would actually be a shift in the methodology itself. |
Also as far as acceptance criteria goes, I think this update should include a new Article on the pkgdown site. |
IMPORTANT: The reprex above does not actually highlight the issue. The "Corporate Economy" in this case starts at |
Yes we do! Sorry, I was meaning to make a reprex and got distracted. Will do so quickly now |
From #316
|
it needs to be fixed here. That is why we removed related issue from |
Agreed! And relates (in a way) to #312 |
Closed by #383 |
The corporate economy outputted by r2dii.analysis::target_market_share is unweighted.
Whereas the projected and targets are weighted (scaled) by the market share of the portfolio.
This is not incorrect in any way however it does cause issues when plotting the different components on the same axis.
i.e. the corporate economy, if plotted in an unweighted form, will be aligned with different scenarios between different portfolios of different sizes.
Hence the corporate economy should be weighted by the same factor as per the targets. i.e. the market share that the portfolio is exposed to.
This then means that the y axis can only ever be given as a proxy and will not be absolute values in any case.
Perhaps we can do both and add an additional value in the "metric column" eg "scaled_corporate_economy"
This way the user can plot appropriately and also assess the corporate economy in its absolute form if they wish.
As I write this I recall that this is almost defiantly what we had done in the past and that it was changed as I questioned it.
I think this is a problem of my own making and sincerely apologies for that.
thanks and let me know
George
The text was updated successfully, but these errors were encountered: