Code Monkey home page Code Monkey logo

pacta.multi.loanbook.analysis's Introduction

pacta.multi.loanbook.analysis

Lifecycle: experimental R-CMD-check

This repository hosts all R functions needed to calculate aggregate alignment metrics for loan books. It also provides plotting functions that help identify patterns within a large set of loan books.

As such these functions are especially useful to assess financial sector level comparison of multiple financial institutions. However, its use is not restricted to that level and input loan books can be (dis)aggregated to any level relevant to the analysis.

All third party data must be input by the user and is not part of this repository. The repository contains some sample data sets that can be used for testing purposes.

pacta.multi.loanbook.analysis's People

Contributors

jacobvjk avatar monikafu avatar jdhoffa avatar cjyetman avatar

Watchers

 avatar  avatar  avatar

pacta.multi.loanbook.analysis's Issues

upkeep: squelch warning in `test-aggregate_alignment_loanbook_exposure.R`

When I run tests locally, I get the following warning

Warning (test-aggregate_alignment_loanbook_exposure.R:41:1): (code run outside of `test_that()`)
Using an external vector in selections was deprecated in tidyselect 1.1.0.
ℹ Please use `all_of()` or `any_of()` instead.
  # Was:
  data %>% select(group_vars)

  # Now:
  data %>% select(all_of(group_vars))

See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
Backtrace:

  1. ├─test_data_aggregate_alignment_loanbook_exposure_net %>% ... at test-aggregate_alignment_loanbook_exposure.R:41:1
  2. ├─pacta.multi.loanbook.analysis::aggregate_alignment_loanbook_exposure(...)
  3. │ └─... %>% ... at pacta.multi.loanbook.analysis/R/aggregate_alignment_loanbook_exposure.R:132:3
  4. ├─dplyr::arrange(...)
  5. ├─dplyr::relocate(...)
  6. └─dplyr:::relocate.data.frame(...)
  7.   └─dplyr:::eval_relocate(...)
  8.     └─tidyselect::eval_select(...)
  9.       └─tidyselect:::eval_select_impl(...)
 10.         ├─tidyselect:::with_subscript_errors(...)
 11.         │ └─rlang::try_fetch(...)
 12.         │   └─base::withCallingHandlers(...)
 13.         └─tidyselect:::vars_select_eval(...)
 14.           └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 15.             └─tidyselect:::eval_c(expr, data_mask, context_mask)
 16.               └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 17.                 └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
 18.                   └─tidyselect:::eval_c(expr, data_mask, context_mask)
 19.                     └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 20.                       └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
 21.                         └─tidyselect:::eval_sym(expr, data_mask, context_mask)

changing this:

dplyr::relocate(
c(
group_vars, "n_companies", "n_companies_aligned",
"share_companies_aligned", "exposure_weighted_net_alignment"
)
) %>%

to this:

    dplyr::relocate(
      dplyr::all_of(
        c(
          group_vars, "n_companies", "n_companies_aligned",
          "share_companies_aligned", "exposure_weighted_net_alignment"
        )
      )
    ) %>%

squelches the warning

feat: use column name `id_loanbook` instead of `group_id`

relates to #33

previously we used the column group_id to identify one variable by which to analyze/aggregate loan books. This is not ideal for the following reasons:

  • users will normally always prepare data by loan book, so it is safe to assume that it is always possible to attribute an identifier to each loan book
  • when analyzing the financial system, there is rarely a situation where we do not care about the individual loan book view
  • group_id does not follow the naming conventions that other id variables in P4B use. It is normally id_* not *_id
  • We still want to be able to analyze/aggregate the data by other dimensions, which we do by passing column names to the new group_var argument (see linked issue). This means that clearer disambiguation of names would be helpful.

AB#10594

add unit tests

  • Add testthat infrastructure
  • test calculate_company_tech_deviation() and underlying functions
  • test calculate_company_aggregate_alignment_tms() and underlying functions
  • test calculate_company_aggregate_alignment_sda() and underlying functions
  • test aggregate_alignment_loanbook_exposure() and underlying functions
  • test create_benchmark_loanbook() and underlying functions

copied from RMI-PACTA/pacta.aggregate.loanbook.plots#46

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.