Skip to content
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

Adding transition risk score #149

Closed
AnneSchoenauer opened this issue Jan 3, 2024 · 5 comments · Fixed by #152
Closed

Adding transition risk score #149

AnneSchoenauer opened this issue Jan 3, 2024 · 5 comments · Fixed by #152
Assignees
Labels
enhancement New feature or request

Comments

@AnneSchoenauer
Copy link

Description:
We need to develop a feature to calculate a transition risk score. This score is an average of two variables: the 'sector_profile_product profile_ranking' and the 'emission_profile_product emission_ranking'. The 'profile_ranking' for the sector is determined by four different scenarios, and the emission 'profile_ranking' is based on six benchmarks, leading to 24 unique combinations.

Task:

  • Develop a function to calculate the transition risk score for all 24 combinations.
  • The score is calculated as the average of the 'profile_ranking' from the sector scenario and the emission ranking from the benchmark.
  • Output should include both the score and the combination name (e.g., 'WEO_2030_isic_sec_unit').

Acceptance Criteria:

  • The function must accurately calculate the transition risk score for each combination.
  • Results should include the combination name and its corresponding score.
  • Code should be clearly documented and tested.

A reproducible example using R and 'dplyr' has been provided for guidance see below. @Tilmon please have a look.

Please reach out if there are any questions or additional details needed.

# Load necessary library
library(dplyr)
#> 
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#> 
#>     filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> 
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#> 
#>     filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tidyr)

# Define the scenarios and their profile rankings
scenarios <- c(WEO_2030 = 0.3, WEO_2050 = 0.7, IPR_2030 = 0.35, IPR_2050 = 0.45)

# Define the benchmarks and their emission rankings
benchmarks <- c(isic_sec_unit = 0.7, isic_sec = 0.6, tilt_sec_unit = 0.6, tilt_sec = 0.5, unit = 0.4, all = 0.4)

# Create a data frame of all combinations
combinations <- expand.grid(scenario = names(scenarios), benchmark = names(benchmarks)) %>%
  mutate(
    transition_risk_score = (scenarios[scenario] + benchmarks[benchmark]) / 2,
    combination_name = paste(scenario, benchmark, sep = "_")
  )

# View the results
print(combinations)
#>    scenario     benchmark transition_risk_score       combination_name
#> 1  WEO_2030 isic_sec_unit                 0.500 WEO_2030_isic_sec_unit
#> 2  WEO_2050 isic_sec_unit                 0.700 WEO_2050_isic_sec_unit
#> 3  IPR_2030 isic_sec_unit                 0.525 IPR_2030_isic_sec_unit
#> 4  IPR_2050 isic_sec_unit                 0.575 IPR_2050_isic_sec_unit
#> 5  WEO_2030      isic_sec                 0.450      WEO_2030_isic_sec
#> 6  WEO_2050      isic_sec                 0.650      WEO_2050_isic_sec
#> 7  IPR_2030      isic_sec                 0.475      IPR_2030_isic_sec
#> 8  IPR_2050      isic_sec                 0.525      IPR_2050_isic_sec
#> 9  WEO_2030 tilt_sec_unit                 0.450 WEO_2030_tilt_sec_unit
#> 10 WEO_2050 tilt_sec_unit                 0.650 WEO_2050_tilt_sec_unit
#> 11 IPR_2030 tilt_sec_unit                 0.475 IPR_2030_tilt_sec_unit
#> 12 IPR_2050 tilt_sec_unit                 0.525 IPR_2050_tilt_sec_unit
#> 13 WEO_2030      tilt_sec                 0.400      WEO_2030_tilt_sec
#> 14 WEO_2050      tilt_sec                 0.600      WEO_2050_tilt_sec
#> 15 IPR_2030      tilt_sec                 0.425      IPR_2030_tilt_sec
#> 16 IPR_2050      tilt_sec                 0.475      IPR_2050_tilt_sec
#> 17 WEO_2030          unit                 0.350          WEO_2030_unit
#> 18 WEO_2050          unit                 0.550          WEO_2050_unit
#> 19 IPR_2030          unit                 0.375          IPR_2030_unit
#> 20 IPR_2050          unit                 0.425          IPR_2050_unit
#> 21 WEO_2030           all                 0.350           WEO_2030_all
#> 22 WEO_2050           all                 0.550           WEO_2050_all
#> 23 IPR_2030           all                 0.375           IPR_2030_all
#> 24 IPR_2050           all                 0.425           IPR_2050_all
#>    scenario     benchmark transition_risk_score       combination_name
#> 1  WEO_2030 isic_sec_unit                 0.500 WEO_2030_isic_sec_unit
#> 2  WEO_2050 isic_sec_unit                 0.700 WEO_2050_isic_sec_unit
#> 3  IPR_2030 isic_sec_unit                 0.525 IPR_2030_isic_sec_unit
#> 4  IPR_2050 isic_sec_unit                 0.575 IPR_2050_isic_sec_unit
#> 5  WEO_2030      isic_sec                 0.450      WEO_2030_isic_sec
#> 6  WEO_2050      isic_sec                 0.650      WEO_2050_isic_sec
#> 7  IPR_2030      isic_sec                 0.475      IPR_2030_isic_sec
#> 8  IPR_2050      isic_sec                 0.525      IPR_2050_isic_sec
#> 9  WEO_2030 tilt_sec_unit                 0.450 WEO_2030_tilt_sec_unit
#> 10 WEO_2050 tilt_sec_unit                 0.650 WEO_2050_tilt_sec_unit
#> 11 IPR_2030 tilt_sec_unit                 0.475 IPR_2030_tilt_sec_unit
#> 12 IPR_2050 tilt_sec_unit                 0.525 IPR_2050_tilt_sec_unit
#> 13 WEO_2030      tilt_sec                 0.400      WEO_2030_tilt_sec
#> 14 WEO_2050      tilt_sec                 0.600      WEO_2050_tilt_sec
#> 15 IPR_2030      tilt_sec                 0.425      IPR_2030_tilt_sec
#> 16 IPR_2050      tilt_sec                 0.475      IPR_2050_tilt_sec
#> 17 WEO_2030          unit                 0.350          WEO_2030_unit
#> 18 WEO_2050          unit                 0.550          WEO_2050_unit
#> 19 IPR_2030          unit                 0.375          IPR_2030_unit
#> 20 IPR_2050          unit                 0.425          IPR_2050_unit
#> 21 WEO_2030           all                 0.350           WEO_2030_all
#> 22 WEO_2050           all                 0.550           WEO_2050_all
#> 23 IPR_2030           all                 0.375           IPR_2030_all
#> 24 IPR_2050           all                 0.425           IPR_2050_all

Created on 2024-01-03 with reprex v2.0.2

@kalashsinghal
Copy link
Collaborator

@AnneSchoenauer What are the other columns you need from the output table other than scenario, benchmark, transition_risk_score , and combination_name? Do you also want the Europages company information in the final output?

@AnneSchoenauer
Copy link
Author

@kalashsinghal Thanks a lot for taking care of this ticket.
I think we would need again a company and a product view for this. So the transition risk score should be there for each product and all 24 benchmarks.
I created here an overview for the product_view.
And here you can find an overview for the company_view.
Please note that I created columns with names that might not be the names that we are using. Let me know if the column names unclear. Would be great if you use the column names that we normally use.

@kalashsinghal
Copy link
Collaborator

@AnneSchoenauer Do you also need transition risk scores for the input products? or for indicators sector_profile_upstream and emissions_profile_upstream?

@AnneSchoenauer
Copy link
Author

For now only for the products.

@Tilmon Tilmon transferred this issue from 2DegreesInvesting/tiltIndicator Jan 30, 2024
@Tilmon
Copy link
Collaborator

Tilmon commented Jan 30, 2024

@kalashsinghal as discussed, please calculate the score in tiltIndicatorAfter only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants