## Scenario market-shares

Say that you want to study how a portfolio would perform in a specific climate scenario. How can you allocate scenario efforts to the production profile of your portfolio? You can do that in two ways – by technology, or by sector.

### 1. Market-share by technology

$p_{i}^{tmsr}(t) = p_{i}(t_0) * \dfrac{s_i(t)}{s_i(t_0)}$

where:

• $$s_i(t)$$ is the scenario production for technology $$i$$ at time $$t$$,
• $$p_{i}(t_0)$$ is the production allocated to the portfolio for some technology, $$i$$ at time $$t_0$$, and
• $$p_{i}^{tmsr}(t)$$ is the portfolio-specific target production for that technology.

We define the “Technology Market Share Ratio” as:

$\dfrac{s_i(t)}{s_i(t_0)}$

### 2. Market-share by sector

$p_{i}^{smsp}(t) = p_{i}(t_0) +P(t_0) * \left( \dfrac{s_i(t)-s_i(t_0)}{S(t_0)}\right)$ where:

• $$P_i(t_0)$$ is the portfolio’s total production in the sector at $$t_0$$, and
• $$S(t_0)$$ is the scenario total production at $$t_0$$.

We define the “Sector Market Share Percentage” as:

$\dfrac{s_i(t)-s_i(t_0)}{S(t_0)}$

## How to calculate market-share targets for a given scenario

To calculate market-share targets, you need to use the package r2dii.analysis and a number of datasets. One of those datasets is a “matched” dataset (loanbook + asset-level data) that you can get with the package r2dii.match. The datasets I use here come from the package r2dii.data; they are fake but show how you should structure your own data.

• Use packages.
library(r2dii.data)
library(r2dii.match)
library(r2dii.analysis)
• Match the loanbook to asset level data.
loanbook <- r2dii.data::loanbook_demo
ald <- r2dii.data::ald_demo

matched <- match_name(loanbook, ald) %>%
# WARNING: Remember to validate the output of match_name() before prioritize()
prioritize()

matched
#> # A tibble: 217 × 28
#>    id_loan id_direct_loanta… name_direct_loan… id_intermediate… name_intermedia…
#>    <chr>   <chr>             <chr>             <chr>            <chr>
#>  1 L6      C304              Yukon Developmen… <NA>             <NA>
#>  2 L13     C297              Yuba City Cogene… <NA>             <NA>
#>  3 L20     C287              Ytl Powerseraya … <NA>             <NA>
#>  4 L21     C286              Ytl Power Intern… <NA>             <NA>
#>  5 L22     C285              Ytl Corp Bhd      <NA>             <NA>
#>  6 L23     C283              Ypic Internation… <NA>             <NA>
#>  7 L24     C282              Ypfb Corporacion  <NA>             <NA>
#>  8 L25     C281              Ypf Sa            <NA>             <NA>
#>  9 L26     C280              Ypf Energia Elec… <NA>             <NA>
#> 10 L27     C278              Younicos Ag       <NA>             <NA>
#> # … with 207 more rows, and 23 more variables: id_ultimate_parent <chr>,
#> #   name_ultimate_parent <chr>, loan_size_outstanding <dbl>,
#> #   loan_size_outstanding_currency <chr>, loan_size_credit_limit <dbl>,
#> #   loan_size_credit_limit_currency <chr>, sector_classification_system <chr>,
#> #   sector_classification_input_type <chr>,
#> #   sector_classification_direct_loantaker <dbl>, fi_type <chr>,
#> #   flag_project_finance_loan <chr>, name_project <lgl>, …
• Calculate market-share targets for production at the portfolio level.
# portfolio level targets
scenario <- r2dii.data::scenario_demo_2020
regions <- r2dii.data::region_isos_demo

matched %>% target_market_share(ald, scenario, regions)
#> # A tibble: 2,334 × 8
#>    sector     technology  year region scenario_source metric     production
#>    <chr>      <chr>      <int> <chr>  <chr>           <chr>           <dbl>
#>  1 automotive electric    2020 global demo_2020       projected     324592.
#>  2 automotive electric    2020 global demo_2020       target_cps    324592.
#>  3 automotive electric    2020 global demo_2020       target_sds    324592.
#>  4 automotive electric    2020 global demo_2020       target_sps    324592.
#>  5 automotive electric    2021 global demo_2020       projected     339656.
#>  6 automotive electric    2021 global demo_2020       target_cps    329191.
#>  7 automotive electric    2021 global demo_2020       target_sds    352505.
#>  8 automotive electric    2021 global demo_2020       target_sps    330435.
#>  9 automotive electric    2022 global demo_2020       projected     354720.
#> 10 automotive electric    2022 global demo_2020       target_cps    333693.
#> # … with 2,324 more rows, and 1 more variable: technology_share <dbl>
• Calculate market-share targets for production at the company level.
matched %>% target_market_share(ald, scenario, regions, by_company = TRUE)
#> Warning: You've supplied by_company = TRUE and weight_production = TRUE.
#> This will result in company-level results, weighted by the portfolio
#> loan size, which is rarely useful. Did you mean to set one of these
#> arguments to FALSE?
#> # A tibble: 32,946 × 9
#>    sector     technology  year region scenario_source name_ald metric production
#>    <chr>      <chr>      <int> <chr>  <chr>           <chr>    <chr>       <dbl>
#>  1 automotive electric    2020 global demo_2020       toyota … proje…    324592.
#>  2 automotive electric    2020 global demo_2020       toyota … targe…    324592.
#>  3 automotive electric    2020 global demo_2020       toyota … targe…    324592.
#>  4 automotive electric    2020 global demo_2020       toyota … targe…    324592.
#>  5 automotive electric    2021 global demo_2020       toyota … proje…    339656.
#>  6 automotive electric    2021 global demo_2020       toyota … targe…    329191.
#>  7 automotive electric    2021 global demo_2020       toyota … targe…    352505.
#>  8 automotive electric    2021 global demo_2020       toyota … targe…    330435.
#>  9 automotive electric    2022 global demo_2020       toyota … proje…    354720.
#> 10 automotive electric    2022 global demo_2020       toyota … targe…    333693.
#> # … with 32,936 more rows, and 1 more variable: technology_share <dbl>