run-country-sensitivity-analysis
Source:vignettes/run-country-sensitivity-analysis.Rmd
run-country-sensitivity-analysis.Rmd
assets_testdata <- read.csv(system.file("testdata", "assets_testdata.csv", package = "trisk.model"))
scenarios_testdata <- read.csv(system.file("testdata", "scenarios_testdata.csv", package = "trisk.model"))
financial_features_testdata <- read.csv(system.file("testdata", "financial_features_testdata.csv", package = "trisk.model"))
ngfs_carbon_price_testdata <- read.csv(system.file("testdata", "ngfs_carbon_price_testdata.csv", package = "trisk.model"))Sensitivity Analysis
Sensitivity analysis allows us to explore how changes in parameters affect the results. In this example, we show how to vary the shock year in multiple TRISK runs when defining run parameters for sensitivity analysis.
run_params <- list(
list(
scenario_geography = "Global",
baseline_scenario = "NGFS2023GCAM_CP",
target_scenario = "NGFS2023GCAM_NZ2050",
shock_year = 2030 # SHOCK YEAR 1
),
list(
scenario_geography = "Global",
baseline_scenario = "NGFS2023GCAM_CP",
target_scenario = "NGFS2023GCAM_NZ2050",
shock_year = 2025 # SHOCK YEAR 2
)
)You can also perform sensitivity analysis on a filtered subset of assets. This example filters the dataset by country, and then runs the analysis.
# Run sensitivity analysis across multiple TRISK runs
sensitivity_analysis_results <- run_trisk_sa(
assets_data = assets_testdata,
scenarios_data = scenarios_testdata,
financial_data = financial_features_testdata,
carbon_data = ngfs_carbon_price_testdata,
run_params = run_params,
country_iso2 = c("DE") # FILTER ASSETS ON COUNTRIES
)
#> [1] "Starting the execution of 2 total runs"
#> -- Processing Assets and Scenarios.
#> -- Transforming to Trisk model input.
#> -- Calculating baseline, target, and shock trajectories.
#> -- Calculating net profits.
#> -- Calculating market risk.
#> -- Calculating credit risk.
#> [1] "Done 1 / 2 total runs"
#> -- Processing Assets and Scenarios.
#> -- Transforming to Trisk model input.
#> -- Calculating baseline, target, and shock trajectories.
#> -- Calculating net profits.
#> -- Calculating market risk.
#> -- Calculating credit risk.
#> [1] "Done 2 / 2 total runs"
#> [1] "All runs completed."Contrary to a simple run of trisk with the “run_trisk” function, here it is possible to navigate through multiple Trisk runs in the same dataframe, using the run_id column as an index.
Consolidated NPV results
knitr::kable(head(sensitivity_analysis_results$npv)) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed")) %>%
kableExtra::scroll_box(width = "100%", height = "400px")| run_id | company_id | asset_id | company_name | asset_name | sector | technology | country_iso2 | net_present_value_baseline | net_present_value_shock |
|---|---|---|---|---|---|---|---|---|---|
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | 101 | Company 1 | Company 1 | Oil&Gas | Gas | DE | 172718.3 | 13549.28 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 102 | 102 | Company 2 | Company 2 | Coal | Coal | DE | 42299475.0 | 4317747.56 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 103 | 103 | Company 3 | Company 3 | Oil&Gas | Gas | DE | 95105145.4 | 24864754.17 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 104 | 104 | Company 4 | Company 4 | Power | RenewablesCap | DE | 497029538.6 | 789241252.58 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 105 | 105 | Company 5 | Company 5 | Power | CoalCap | DE | 176175702.5 | 11874146.56 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 105 | 105 | Company 5 | Company 5 | Power | OilCap | DE | 21412749.3 | 1416673.16 |
Consolidated PD results
knitr::kable(head(sensitivity_analysis_results$pd)) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed")) %>%
kableExtra::scroll_box(width = "100%", height = "400px")| run_id | company_id | company_name | sector | term | pd_baseline | pd_shock |
|---|---|---|---|---|---|---|
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | Oil&Gas | 1 | 0.0000000 | 0.0382660 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | Oil&Gas | 2 | 0.0000000 | 0.1121338 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | Oil&Gas | 3 | 0.0000011 | 0.1680445 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | Oil&Gas | 4 | 0.0000237 | 0.2098967 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | Oil&Gas | 5 | 0.0001502 | 0.2425541 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 102 | Company 2 | Coal | 1 | 0.0000000 | 0.0197957 |
Consolidated company trajectories
knitr::kable(head(sensitivity_analysis_results$trajectories)) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed")) %>%
kableExtra::scroll_box(width = "100%", height = "400px")| run_id | asset_id | asset_name | company_id | company_name | year | sector | technology | production_plan_company_technology | production_baseline_scenario | production_target_scenario | production_shock_scenario | pd | net_profit_margin | debt_equity_ratio | volatility | scenario_price_baseline | price_shock_scenario | net_profits_baseline_scenario | net_profits_shock_scenario | discounted_net_profits_baseline_scenario | discounted_net_profits_shock_scenario |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | 101 | Company 1 | 2022 | Oil&Gas | Gas | 5000 | 5000 | 5000.000 | 5000 | 0.0056224 | 0.0763542 | 0.1297317 | 0.259323 | 5.867116 | 5.867116 | 2239.895 | 2239.895 | 2239.895 | 2239.895 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | 101 | Company 1 | 2023 | Oil&Gas | Gas | 5423 | 5423 | 5001.354 | 5423 | 0.0056224 | 0.0763542 | 0.1297317 | 0.259323 | 5.898569 | 5.898569 | 2442.414 | 2442.414 | 2282.630 | 2282.630 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | 101 | Company 1 | 2024 | Oil&Gas | Gas | 6200 | 6200 | 5002.708 | 6200 | 0.0056224 | 0.0763542 | 0.1297317 | 0.259323 | 5.930022 | 5.930022 | 2807.250 | 2807.250 | 2451.961 | 2451.961 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | 101 | Company 1 | 2025 | Oil&Gas | Gas | 7400 | 7400 | 5004.062 | 7400 | 0.0056224 | 0.0763542 | 0.1297317 | 0.259323 | 5.961475 | 5.961475 | 3368.360 | 3368.360 | 2749.585 | 2749.585 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | 101 | Company 1 | 2026 | Oil&Gas | Gas | 7800 | 7800 | 4862.620 | 7800 | 0.0056224 | 0.0763542 | 0.1297317 | 0.259323 | 5.945170 | 5.945170 | 3540.723 | 3540.723 | 2701.201 | 2701.201 |
| 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca | 101 | Company 1 | 101 | Company 1 | 2027 | Oil&Gas | Gas | 8600 | 8600 | 4721.178 | 8600 | 0.0056224 | 0.0763542 | 0.1297317 | 0.259323 | 5.928866 | 5.928866 | 3893.168 | 3893.168 | 2775.775 | 2775.775 |
Consolidated params dataframe
knitr::kable(head(sensitivity_analysis_results$params)) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed")) %>%
kableExtra::scroll_box(width = "100%", height = "400px")| baseline_scenario | target_scenario | scenario_geography | carbon_price_model | risk_free_rate | discount_rate | growth_rate | div_netprofit_prop_coef | shock_year | market_passthrough | run_id |
|---|---|---|---|---|---|---|---|---|---|---|
| NGFS2023GCAM_CP | NGFS2023GCAM_NZ2050 | Global | no_carbon_tax | 0.02 | 0.07 | 0.03 | 1 | 2030 | 0 | 65b8ff32-14b8-47f0-9b6a-1274b2b2ecca |
| NGFS2023GCAM_CP | NGFS2023GCAM_NZ2050 | Global | no_carbon_tax | 0.02 | 0.07 | 0.03 | 1 | 2025 | 0 | e5052186-bd80-41ce-9746-7a0f89c76d12 |
Plot results
Plot the sum of production trajectories, scaled in percentage of the first year value. The run_id identifies each run and can be found in the parameters dataframe.
plot_multi_trajectories(sensitivity_analysis_results$trajectories)