12  Deploying the model

12.1 Overview

ems_deploy() validates all data and model inputs, processes shocks and closure swaps, and writes all required input files to disk. The output file path serves as a required input to ems_solve().

12.2 Arguments

Argument Default Description
.data A list of data.tables generated by ems_data()
model A tibble generated by ems_model()
shock NULL A shock object or list of shock objects produced by ems_uniform_shock(), ems_custom_shock(), or ems_scenario_shock(). When NULL, no shock is applied and input data is returned without change
swap_in NULL A character vector, list generated by ems_swap(), or combination provided as a list. Variables to be made exogenous
swap_out NULL A character vector, list generated by ems_swap(), or combination provided as a list. Variables to be made endogenous
shock_file NULL Path to a file with .shf extension representing a fully prepared shock file. No checks or modifications are carried out on this file

12.3 Basic usage

The simplest deployment requires only data and model inputs. With no shock supplied, input data is returned without change:

cmf_path <- ems_deploy(
  .data = dat,
  model = model
)

12.4 Deploying with shocks and swaps

A single shock can be passed directly:

shock <- ems_uniform_shock(var = "pop", value = 1)

cmf_path <- ems_deploy(
  .data = dat,
  model = model,
  shock = shock
)

Multiple shocks are combined in a list:

pop_shk <- ems_uniform_shock(var = "pop", value = 1)
aoall_shk <- ems_custom_shock(var = "aoall", input = aoall_df)

cmf_path <- ems_deploy(
  .data = dat,
  model = model,
  shock = list(pop_shk, aoall_shk)
)

12.5 Closure swaps

A single full variable swap swaps one variable in and one out using plain strings:

shock <- ems_uniform_shock(var = "qfd", value = 1)

cmf_path <- ems_deploy(
  .data = dat,
  model = model,
  shock = shock,
  swap_in = "qfd",
  swap_out = "tfd"
)

Multiple full variable swaps are passed as character vectors. Partial swaps use ems_swap() objects and can be mixed with strings in a list:

# Multiple full variable swaps
cmf_path <- ems_deploy(
  .data = dat,
  model = model,
  shock = shock,
  swap_in = c("qfd", "yp"),
  swap_out = c("tfd", "dppriv")
)

# Mixed partial and full swaps
yp_row <- ems_swap("yp", REGr = "row")
dppriv_row <- ems_swap("dppriv", REGr = "row")

cmf_path <- ems_deploy(
  .data = dat,
  model = model,
  shock = shock,
  swap_in = list(yp_row, "qfd"),
  swap_out = list(dppriv_row, "tfd")
)

12.6 User-generated inputs

ems_deploy() allows for user-generated shock files via the shock_file argument. In the case of shock files, no checks or operations will be conducted (i.e., the shock file as loaded is considered the final input). User-supplied closure files will however be processed if swaps are supplied.