Skip to content

Commit

Permalink
move by_group param to project_parameters (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobvjk authored Sep 18, 2024
1 parent c6fc5fe commit 0bc6fa2
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 26 deletions.
4 changes: 2 additions & 2 deletions R/load_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ get_region_select <- function(params) {
params[["project_parameters"]][["region_select"]]
}

get_aggregate_alignment_metric_by_group <- function(params) {
params[["aggregate_alignment_metric"]][["by_group"]]
get_by_group <- function(params) {
params[["project_parameters"]][["by_group"]]
}

get_match_priority <- function(params) {
Expand Down
2 changes: 1 addition & 1 deletion R/plot_aggregate_loanbooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ plot_aggregate_loanbooks <- function(config) {
output_path_aggregated <- file.path(output_path, sector_split_type_select, "aggregated")
}

by_group <- get_aggregate_alignment_metric_by_group(config)
by_group <- get_by_group(config)
by_group <- check_and_prepare_by_group(by_group)

dir.create(output_path_aggregated, recursive = TRUE, showWarnings = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/run_aggregate_alignment_metric.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ run_aggregate_alignment_metric <- function(config) {
start_year <- get_start_year(config)
time_frame <- get_time_frame(config)

by_group <- get_aggregate_alignment_metric_by_group(config)
by_group <- get_by_group(config)
by_group <- check_and_prepare_by_group(by_group)

# load input data----
Expand Down
2 changes: 1 addition & 1 deletion R/run_calculate_loanbook_coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ run_calculate_loanbook_coverage <- function(config) {
scenario_source_input <- get_scenario_source(config)
start_year <- get_start_year(config)

by_group <- get_aggregate_alignment_metric_by_group(config)
by_group <- get_by_group(config)
by_group <- check_and_prepare_by_group(by_group)
by_group_ext <- if (is.null(by_group)) { "_meta" } else { paste0("_", by_group) }

Expand Down
2 changes: 1 addition & 1 deletion R/run_calculate_match_success_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ run_calculate_match_success_rate <- function(config) {
path_own_sector_classification <- get_manual_sector_classification_path(config)
}

by_group <- get_aggregate_alignment_metric_by_group(config)
by_group <- get_by_group(config)
by_group <- check_and_prepare_by_group(by_group)
by_group_ext <- if (is.null(by_group)) { "_meta" } else { paste0("_", by_group) }

Expand Down
2 changes: 1 addition & 1 deletion R/run_pacta.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ run_pacta <- function(config) {

dir.create(output_path_standard, recursive = TRUE, showWarnings = FALSE)

by_group <- get_aggregate_alignment_metric_by_group(config)
by_group <- get_by_group(config)
by_group <- check_and_prepare_by_group(by_group)
by_group_ext <- if (is.null(by_group)) { "_meta" } else { paste0("_", by_group) }

Expand Down
3 changes: 1 addition & 2 deletions example.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ default:
# the scenario in use
start_year: 2022
time_frame: 5
by_group: "group_id"
sector_split:
apply_sector_split: TRUE
sector_split_type: "equal_weights"
Expand Down Expand Up @@ -47,5 +48,3 @@ default:
plot_height: 8
plot_units: "in"
plot_resolution: 300
aggregate_alignment_metric:
by_group: "group_id"
26 changes: 9 additions & 17 deletions vignettes/config_yml.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ A full example `project_parameters`{.yaml} section might look like:
region_select: "global"
start_year: 2022
time_frame: 5
by_group: "group_id"
```

#### scenario_source
Expand Down Expand Up @@ -176,6 +177,14 @@ A full example `project_parameters`{.yaml} section might look like:
time_frame: 5
```

#### by_group

`by_group`{.yaml} allows specifying the level of disaggregation to be used in the analysis. It determines the variable along which the loan books are grouped and thus the dimension by which to compare the PACTA calculations. For example, one may want to calculate system-wide results without disaggregation, using `NULL`{.yaml} or one may want to analyse alignment along bank specific traits, such as `"group_id"`{.yaml} or `"bank_type"`{.yaml}. It can be `NULL`{.yaml} or a character vector of length 1. If it is not `NULL`{.yaml}, the indicated name must be a variable that is provided in the input loan books and it must be complete (`"group_id"` is automatically created when reading in the loan books, so the user does not have to add it to the raw loan books). If the provided character string is `"NULL"`{.yaml}, it will be treated as `NULL`{.yaml}. As an example:

```yaml
by_group: "group_id"
```

## sector_split:

A full example `sector_split`{.yaml} section might look like:
Expand Down Expand Up @@ -439,20 +448,3 @@ A full example `match_success_rate`{.yaml} section might look like:
```yaml
plot_resolution: 300
```

## aggregate_alignment_metric:

A full example `aggregate_alignment_metric`{.yaml} section might look like:

```yaml
aggregate_alignment_metric:
by_group: "group_id"
```

#### by_group

`by_group`{.yaml} allows specifying the level of disaggregation to be used in the analysis. It determines the variable along which the loan books are grouped and thus the dimension by which to compare the PACTA calculations. For example, one may want to calculate system-wide results without disaggregation, using `NULL`{.yaml} or one may want to analyse alignment along bank specific traits, such as `"group_id"`{.yaml} or `"bank_type"`{.yaml}. It can be `NULL`{.yaml} or a character vector of length 1. If it is not `NULL`{.yaml}, the indicated name must be a variable that is provided in the input loan books and it must be complete (`"group_id"` is automatically created when reading in the loan books, so the user does not have to add it to the raw loan books). If the provided character string is `"NULL"`{.yaml}, it will be treated as `NULL`{.yaml}. As an example:

```yaml
by_group: "group_id"
```

0 comments on commit 0bc6fa2

Please sign in to comment.