# Example 1: Target-Based Shock Calculation
har_path <- system.file("extdata", "baserate.har", package = "HARplus")
# Sorting Column
mapping <- list(
REG = c("USA", "EU", "ROW")
)
# Initial File
initial <- create_initial_config(
path = har_path,
format = "har",
header = "rTMS"
)
# Target File
target <- create_target_config(
path = har_path,
type = "har",
header = "rTMS"
)
# Calculation Setup with Column Mapping
calc <- create_calc_config(
column_mapping = c(TRAD_COMM = "TRAD_COMM", REG = "REG", REG.1 = "REG.1"),
timeline = "1-5",
exclude_self_trade = TRUE
)
# Compute Shock Based on Initial and Target Values
shock_calculate(
initial_config = initial,
target_config = target,
calc_config = calc,
output_path = file.path(tempdir(), "output_target.har"),
dim_order = mapping
)
Run the code above in your browser using DataLab