knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette describes in detail how an analysis can be configured further by providing more custom data. The configurations are not required but, in case additional information is available, may help you improve the accuracy of your results.
In order to keep this vignette concise, we assume the following has been set up:
r2dii.climate.stress.test
. Note that this may require installing additional
packages. You will be prompted to install these in case any are missing.In order to keep this vignette concise, we assume that you have successfully completed all preparation steps described in the vignettes Set up project directories.
Financial data provide several financial indicators on the company level. If data is available you can replace our standard financial data set with a data set holding your financial information on the companies you included in the analysis.
The data that needs to be created is a csv file named
prewrangled_financial_data_stress_test.csv
to replace the default
prewrangled_financial_data_stress_test.csv
file.
It holds the columns:
company_name
: character, holding the name of analysed companies.company_id
: numeric, the id of company as classified by asset resolution.
For loans workflow a placeholder value will be used.corporate_bond_ticker
: character, holding the identifier. Will be NA for
loans workflow.pd
: numeric, holding the probability of default per company. Needs to be
equal to or larger than 0 and smaller than 1.net_profit_margin
: numeric, holding the net_profit_margin per company. Needs
to be larger than 0 and equal to or smaller than 1.debt_equity_ratio
: numeric, holding the ratio of outstanding debt to the
company's equity value. This is the company's financial leverage. Needs to be
larger than 0. volatility
: numeric, holding the volatility of asset. Needs to be equal to
or larger than 0.NOTE: No column, except for corporate_bond_ticker, may have missing values.
In column company_name
include all unique company names from
Loans_results_company.rda
, which you generated in prepare loans
inputs.
Running the following code will generate a dataset with all required columns.
Column campany_name
includes the unique company names, company_id
includes a
placeholder id, all other columns are empty.
library(readr) library(r2dii.climate.stress.test) loans_results_company_file_path <- file.path("/example_project/project_specific_input", "Loans_results_company.rda") validate_file_exists(loans_results_company_file_path) data <- readr::read_rds(loans_results_company_file_path) fin_companies <- data %>% dplyr::select(company_name) %>% dplyr::distinct() %>% dplyr::mutate( company_id = 999, corporate_bond_ticker = NA, pd = NA, net_profit_margin = NA, debt_equity_ratio = NA, volatility = NA ) readr::write_csv(fin_companies, file.path("/example_project/project_agnostic_input", "prewrangled_financial_data_stress_test.csv")) # NOTE that this will overwrite financial data currently stored at the location if available
You can now open this file in a tool of your choice and fill in values for the
remaining variables. For column company_id
keep using a placeholder value
(999 in example) and leave entries for corporate_bond_ticker
as NA. Please make
sure to save the result as a csv file again.
Before including the file in your analysis you may want to validate that your file complies with requirements concerning structure and content. You may verify by executing the following lines of code. You will receive warning/error messages in case problems are detected.
library(readr) library(r2dii.climate.stress.test) financial_data_path <- file.path( "/example_project/project_agnostic_input", "prewrangled_financial_data_stress_test.csv" ) validate_file_exists(financial_data_path) data <- readr::read_csv(financial_data_path) check_financial_data(financial_data = data, asset_type = "loans", interactive_mode = TRUE)
In order to make sure your version
of prewrangled_financial_data_stress_test.csv
is used in the analysis place it
in
project_agnostic_input/
as set up in Set up project directories. If the respective dataset as provided by 2DII already exists there make sure to replace it with your custom file.
You can now run the stress test as described in vignette Run stress test.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.