You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a large misconception in my understanding of how we should calculate the "technology mix" metric.
It was my understanding that we simply take the relative portfolio-weight of each company (the loan size to that company divided by the total loans to that sector), and multiply that by the actual production in each technology. This is correct for the Volume Trajectory, but the Technology Mix is a little more subtle.
For the technology mix, we should actually multiply the technology share of each company by the portfolio-weight. It's a subtle difference but affects the results significantly.
I will prioritize this immediately post-vacation and will aim to have the feature added before a second CRAN release that week.
This result CAN actually be achieved with the current code and a bit of massaging. See the following reprex:
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union
library(r2dii.data)
library(r2dii.match)
library(r2dii.analysis)
# This is just a demo, but you should use your actual portfolio "match_result" filematch_result<-loanbook_demo %>%
match_name(ald_demo) %>%
prioritize()
# First we will use the match results to calculate the sectoral portfolio-weight# of each company in your loanbook. Note: we use loan_size_outstanding here.# Use credit limit if you wish.portfolio_weights<-match_result %>%
select(id_loan, loan_size_outstanding, name_ald, sector_ald) %>%
group_by(sector_ald) %>%
mutate(
sector_total= sum(loan_size_outstanding),
portfolio_weight=loan_size_outstanding/sector_total
) %>%
select(name_ald, sector_ald, portfolio_weight)
ungroup()
#> Error in UseMethod("ungroup"): no applicable method for 'ungroup' applied to an object of class "NULL"# Then we will calculate the RAW technology mix of each company (using their# FULL production), ie. `company_technology_mix`. We will then join in the# portfolio weights, and weight the technology mix, ie.# `portfolio_technology_share`.company_level_results<-match_result %>%
target_market_share(
ald_demo,
scenario_demo_2020,
region_isos_demo,
by_company=TRUE,
weight_production=FALSE
) %>%
select(-c(tmsr, smsp)) %>%
filter(production_metric=="projected") %>%
group_by(name_ald, year) %>%
mutate(
sector_total= sum(production_value),
company_technology_share=production_value/sector_total
) %>%
left_join(
portfolio_weights, by= c(
name_ald="name_ald",
sector="sector_ald"
)
) %>%
mutate(
portfolio_technology_share=portfolio_weight*company_technology_share
)
#> Adding missing grouping variables: `tmsr`, `smsp`# We will then aggregate and re-normalize this "weighted mix of technologies" to# get the portfolio's actual technology mixportfolio_level_results<-company_level_results %>%
group_by(sector, technology, year, region) %>%
summarize(portfolio_technology_mix= sum(company_technology_share)) %>%
group_by(sector, year, region) %>%
mutate(
x=portfolio_technology_mix,
portfolio_technology_mix=x/ sum(x),
x=NULL
)
#> `summarise()` regrouping output by 'sector', 'technology', 'year' (override with `.groups` argument)
I had a large misconception in my understanding of how we should calculate the "technology mix" metric.
It was my understanding that we simply take the relative portfolio-weight of each company (the loan size to that company divided by the total loans to that sector), and multiply that by the actual production in each technology. This is correct for the Volume Trajectory, but the Technology Mix is a little more subtle.
For the technology mix, we should actually multiply the technology share of each company by the portfolio-weight. It's a subtle difference but affects the results significantly.
I will prioritize this immediately post-vacation and will aim to have the feature added before a second CRAN release that week.
This result CAN actually be achieved with the current code and a bit of massaging. See the following reprex:
Created on 2020-08-21 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: