Skip to contents
library(trisk.analysis)
library(trisk.model)
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

Download the data

Set the download path

trisk_inputs_folder <- file.path(".", "trisk_inputs")

Download the data

download_success <- download_trisk_inputs(local_save_folder = trisk_inputs_folder)
#> Download completed.

Descriptive statistics

Sectors covered by scenarios

if (download_success) {
  scenarios <- read.csv(file.path(trisk_inputs_folder, "scenarios.csv"))
  number_of_scenario_per_sector <- scenarios %>%
    distinct(scenario, sector, technology) %>%
    group_by(sector, technology) %>%
    summarise(n_scenarios = n())
}
#> `summarise()` has grouped output by 'sector'. You can override using the
#> `.groups` argument.
if (download_success) {
  knitr::kable(number_of_scenario_per_sector) %>%
    kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed")) %>%
    kableExtra::scroll_box(width = "100%", height = "400px")
}
sector technology n_scenarios
Automotive Electric 8
Automotive FuelCell 8
Automotive Hybrid 8
Automotive ICE 8
Coal Coal 32
Oil&Gas Gas 32
Oil&Gas Oil 32
Power CoalCap 32
Power GasCap 32
Power HydroCap 32
Power NuclearCap 32
Power OilCap 32
Power RenewablesCap 32
Steel BOF-BF 2
Steel BOF-DRI 2
Steel EAF-BF 2
Steel EAF-DRI 2
Steel EAF-MM 2
Steel EAF-OHF 2

Example Run

Load downloaded data

if (download_success) {
  assets <- read.csv(file.path(trisk_inputs_folder, "assets.csv"))
  scenarios <- read.csv(file.path(trisk_inputs_folder, "scenarios.csv"))
  financial_data <- read.csv(file.path(trisk_inputs_folder, "financial_features.csv"))
  carbon_data <- read.csv(file.path(trisk_inputs_folder, "ngfs_carbon_price.csv"))
}

Run Trisk on this data

if (download_success) {
  st_results <- run_trisk_model(
    assets_data = assets,
    scenarios_data = scenarios,
    financial_data = financial_data,
    carbon_data = carbon_data,
    baseline_scenario = "NGFS2023GCAM_CP",
    target_scenario = "NGFS2023GCAM_NZ2050",
    scenario_geography = "Global"
  )
}
#> -- Processing Assets and Scenarios. 
#> -- Transforming to Trisk model input. 
#> -- Calculating baseline, target, and shock trajectories. 
#> -- Calculating net profits. 
#> -- Calculating market risk. 
#> -- Calculating credit risk.
if (download_success) {
  print(names(st_results))
}
#> [1] "npv_results"          "pd_results"           "company_trajectories"