| shock_calculate_uniform | R Documentation |
Generates GEMPACK-style percentage shocks using a uniform proportional adjustment applied to all values in the initial dataset. The function supports additive or multiplicative adjustments, single or multi-period configurations, and direct HAR export.
shock_calculate_uniform(
initial_config,
adjustment_value,
calculation_method = "*",
calc_config,
output_path,
long_desc = "Uniform shock adjustment",
dim_order = NULL,
lowercase = FALSE
)
initial_config |
A list created by
|
adjustment_value |
Numeric scalar specifying the uniform adjustment to apply.
|
calculation_method |
Operator defining the adjustment method:
|
calc_config |
A list created by
|
output_path |
Path to the output HAR file where calculated shocks will be written. |
long_desc |
Optional text for header description. Default is "Uniform shock adjustment". |
dim_order |
Optional dimension ordering specification. Can be:
|
lowercase |
Logical; if TRUE, converts all dimension elements to lowercase. Default is FALSE. |
Applies uniform adjustment to all base rates across defined dimensions
Supports additive ("+", "-") and proportional ("*", "/") adjustments
Computes compounded shocks following the "power of tax" formulation
Handles multiple time periods as defined by timeline in calc_config
Excludes self-trade or specified region/sector pairs if configured
Outputs results as multi-header HAR file (one per timeline period)
Invisibly returns a list containing summary metadata:
n_observations: total records processed
n_included: records included in shock computation
n_excluded: records excluded by configuration
output_path: normalized path to the generated HAR file
Pattawee Puangchit
shock_calculate, create_initial_config,
create_calc_config, save_har
# Example 1: Uniform Shock (50% Reduction)
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"
)
# Calculation Setup
calc <- create_calc_config(
timeline = "1-10",
exclude_self_trade = TRUE
)
# Compute Uniform 50% Reduction (Value_tar = Value_ini * 0.5)
shock_calculate_uniform(
initial_config = initial,
adjustment_value = 0.5,
calculation_method = "*",
calc_config = calc,
output_path = file.path(tempdir(), "output_uniform.har"),
dim_order = mapping
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.