| Title: | Trade and Environment Equilibrium Modeling System |
|---|---|
| Description: | Equilibrium models are frequently employed to examine the potential impacts of economic, energy, and trade policies as well as form the foundation of most integrated assessment models. The 'teems' package handles all aspects of running equilibrium models while facilitating transparent and reproducible workflows. |
| Authors: | Matthew Cantele [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-3729-1764>), Tom Kompas [ctb, ths] (ORCID: <https://orcid.org/0000-0002-0665-0966>), Ha Van Pham [ctb] (ORCID: <https://orcid.org/0000-0002-5927-6568>), Martin Ingram [ctb] (ORCID: <https://orcid.org/0000-0001-6269-8342>) |
| Maintainer: | Matthew Cantele <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 0.1.1 |
| Built: | 2026-06-18 09:10:01 UTC |
| Source: | https://github.com/teemsphere/teems |
ems_compose() retrieves and processes results
from a solved model run. Data validation and consistency
checks are performed during composition.
ems_compose(cmf_path, which = "all")ems_compose(cmf_path, which = "all")
cmf_path |
Character length 1, path to the CMF file
generated by |
which |
Character vector of variable length (default
|
A tibble with columns "name", "label", "type", and "dat" (a list-column of data.tables) containing model results.
ems_solve() for solving the CGE model.
## Not run: # The following examples require that a model run has taken # place. See https://teemsphere.github.io/ to get started. # Return all variables and coefficients outputs <- ems_compose(cmf_path) # Return specific variables and/or coefficients by name outputs <- ems_compose(cmf_path, c("qfd", "EVFP")) ## End(Not run)## Not run: # The following examples require that a model run has taken # place. See https://teemsphere.github.io/ to get started. # Return all variables and coefficients outputs <- ems_compose(cmf_path) # Return specific variables and/or coefficients by name outputs <- ems_compose(cmf_path, c("qfd", "EVFP")) ## End(Not run)
Prepares heterogeneous percentage-change shocks
specified on a tuple-by-tuple basis. Only the tuples present
in input are shocked.
ems_custom_shock(var, input)ems_custom_shock(var, input)
var |
Character of length 1, the variable to be shocked. |
input |
Path to a CSV file, or a data frame or data frame
extension (e.g., tibble, data.table). Must contain one
column named |
A list object with shock configuration to be passed
to the shock argument of ems_deploy().
ems_deploy() for loading the output of this
function, ems_swap() for changing the standard model
closure.
# Set elements sectors <- c("crops", "food", "livestock", "mnfcs", "svces") regions <- c("asia", "eit", "lam", "maf", "oecd") time_steps <- 0:7 # Create data frame aoall_data <- expand.grid(ACTSa = sectors, REGr = regions, ALLTIMEt = time_steps) aoall_data$Value <- runif(nrow(aoall_data)) head(aoall_data) # Assign values to a model variable (aoall) ems_custom_shock("aoall", aoall_data) # In the case of temporally dynamic models, chronological # year(s) specified by the column "Year" may be used instead # of the the time set. pop_data <- data.frame(REGr = "asia", Year = 2023:2030) pop_data$Value <- runif(nrow(pop_data)) pop_data ems_custom_shock("pop", pop_data)# Set elements sectors <- c("crops", "food", "livestock", "mnfcs", "svces") regions <- c("asia", "eit", "lam", "maf", "oecd") time_steps <- 0:7 # Create data frame aoall_data <- expand.grid(ACTSa = sectors, REGr = regions, ALLTIMEt = time_steps) aoall_data$Value <- runif(nrow(aoall_data)) head(aoall_data) # Assign values to a model variable (aoall) ems_custom_shock("aoall", aoall_data) # In the case of temporally dynamic models, chronological # year(s) specified by the column "Year" may be used instead # of the the time set. pop_data <- data.frame(REGr = "asia", Year = 2023:2030) pop_data$Value <- runif(nrow(pop_data)) pop_data ems_custom_shock("pop", pop_data)
Loads input files, aggregates basedata and
parameters according to set mappings, and returns prepared
data for ems_deploy(). Accepts GTAP HAR files and
objects generated by GTAP_convert() as inputs.
ems_data(dat_input, par_input, set_input, time_steps = NULL, ...)ems_data(dat_input, par_input, set_input, time_steps = NULL, ...)
dat_input |
Character vector of length 1, file name in
working directory or path to a data input containing
basedata coefficient data, or the corresponding "dat" list
object generated by |
par_input |
Character vector of length 1, file name in
working directory or path to a data input containing
parameter coefficient data, or the corresponding "par" list
object generated by |
set_input |
Character vector of length 1, file name in
working directory or path to a data input containing set
elements and attributes, or the corresponding "set" list
object generated by |
time_steps |
Integer vector of variable length (default
is |
... |
A named pairlist assigning set mappings to model sets that are explicitly read (not constructed via any set operation defined in the model file). Set mappings can be selected from a range of internally available options or provided by the user.
See teems-mappings for internally available mappings and formatting for user-provided mappings. |
Set names passed via ... must match set names as
they appear in the database. Only sets requiring aggregation
need to be specified. Unspecified sets whose elements are
fully covered by a provided mapping are derived
automatically. Any elements not covered by a provided
mapping are passed through without aggregation.
A list of data.tables ready for input into the .data
argument of ems_deploy()
ems_deploy() for loading the output of this
function. GTAP_convert() for converting GTAP HAR files
and data formats.
## Not run: # The following examples require input data. See # https://teemsphere.github.io/ to get started. # Data for a static model using internal mappings v7_data <- ems_data("v7_data/gsdfdat.har", "v7_data/gsdfpar.har", "v7_data/gsdfset.har", REG = "AR5", ACTS = "food", ENDW = "labor_diff") # Data for an intertemporal model with explicit time steps int_data <- ems_data("v6_data/gsddat.har", "v6_data/gsdpar.har", "v6_data/gsdset.har", REG = "WB23", PROD_COMM = "services", ENDW_COMM = "labor_agg", time_steps = c(0, 1, 2, 4, 6, 8, 10, 15)) # Data for an intertemporal model with chronological time # steps and a user-provided mapping for the ENDW set int_data <- ems_data("v7_data/gsdfdat.har", "v7_data/gsdfpar.har", "v7_data/gsdfset.har", REG = "R32", ACTS = "medium", ENDW = "user/endowment/mapping.csv", time_steps = c(2023, 2025, 2027, 2030, 2035)) ## End(Not run)## Not run: # The following examples require input data. See # https://teemsphere.github.io/ to get started. # Data for a static model using internal mappings v7_data <- ems_data("v7_data/gsdfdat.har", "v7_data/gsdfpar.har", "v7_data/gsdfset.har", REG = "AR5", ACTS = "food", ENDW = "labor_diff") # Data for an intertemporal model with explicit time steps int_data <- ems_data("v6_data/gsddat.har", "v6_data/gsdpar.har", "v6_data/gsdset.har", REG = "WB23", PROD_COMM = "services", ENDW_COMM = "labor_agg", time_steps = c(0, 1, 2, 4, 6, 8, 10, 15)) # Data for an intertemporal model with chronological time # steps and a user-provided mapping for the ENDW set int_data <- ems_data("v7_data/gsdfdat.har", "v7_data/gsdfpar.har", "v7_data/gsdfset.har", REG = "R32", ACTS = "medium", ENDW = "user/endowment/mapping.csv", time_steps = c(2023, 2025, 2027, 2030, 2035)) ## End(Not run)
Validates all data and model inputs, processes
shocks and closure swaps, and writes the input files
required by ems_solve().
ems_deploy( .data, model, shock = NULL, swap_in = NULL, swap_out = NULL, shock_file = NULL )ems_deploy( .data, model, shock = NULL, swap_in = NULL, swap_out = NULL, shock_file = NULL )
.data |
A list of data.tables generated by
|
model |
A tibble generated by |
shock |
A |
swap_in |
A character vector of variable length, list
generated by |
swap_out |
A character vector of variable length, list
generated by |
shock_file |
A character vector length 1 (default
|
Path to the CMF file, to be passed to ems_solve().
ems_data() for loading and preparing data inputs.
ems_model() for parsing and modifying model and closure
files. ems_uniform_shock(), ems_custom_shock(), and
ems_scenario_shock() for preparing shocks.
ems_swap() for preparing closure swaps. ems_solve()
for utilizing the output of this function.
## Not run: # The following examples require input data. See # https://teemsphere.github.io/ to get started. # Uniform shock applied to full variable with value 1 shock <- ems_uniform_shock("qfd", value = 1) # Full variable swap, qfd for tfd cmf_path <- ems_deploy( .data = dat, model = model, shock = shock, swap_in = "qfd", swap_out = "tfd" ) # Partial variable swap (element "row" of set REG with index r) yp_row <- ems_swap("yp", REGr = "row") dppriv_row <- ems_swap("dppriv", REGr = "row") # Swap part of yp for part of dppriv; qfd for tfd cmf_path <- ems_deploy( .data = dat, model = model, shock = shock, swap_in = list(yp_row, "qfd"), swap_out = list(dppriv_row, "tfd") ) ## End(Not run)## Not run: # The following examples require input data. See # https://teemsphere.github.io/ to get started. # Uniform shock applied to full variable with value 1 shock <- ems_uniform_shock("qfd", value = 1) # Full variable swap, qfd for tfd cmf_path <- ems_deploy( .data = dat, model = model, shock = shock, swap_in = "qfd", swap_out = "tfd" ) # Partial variable swap (element "row" of set REG with index r) yp_row <- ems_swap("yp", REGr = "row") dppriv_row <- ems_swap("dppriv", REGr = "row") # Swap part of yp for part of dppriv; qfd for tfd cmf_path <- ems_deploy( .data = dat, model = model, shock = shock, swap_in = list(yp_row, "qfd"), swap_out = list(dppriv_row, "tfd") ) ## End(Not run)
The teems package includes example models and scripts. This function facilitates access to both, allowing new users to immediately peruse compatible models or generate scripts containing a range of package features.
ems_example( model, path, type = c("model_files", "scripts"), dat_input = NULL, par_input = NULL, set_input = NULL )ems_example( model, path, type = c("model_files", "scripts"), dat_input = NULL, par_input = NULL, set_input = NULL )
model |
Character vector of length 1, name of model. Options include:
|
path |
Character vector of length 1. Directory where files will be written. |
type |
Character vector of length 1, (default is
|
dat_input |
Character vector of length 1 (default is
|
par_input |
Character vector of length 1 (default is
|
set_input |
Character vector of length 1 (default is
|
For type = "model_files": a named character vector
with elements model_file and closure_file. For type = "scripts": a character vector of paths to the written
script files.
GTAP_convert() for converting GTAP HAR files and
data formats.
# Retrieve GTAP-RE model files ems_example("GTAP-RE", tempdir()) ## Not run: # The following example requires input data. See # https://teemsphere.github.io/ to get started. # Generate GTAP-RE example scripts ems_example(model = "GTAP-RE", path = "path/to/example/scripts", type = "scripts", dat_input = "v7_data/gsdfdat.har", par_input = "v7_data/gsdfpar.har", set_input = "v7_data/gsdfset.har") # Generate GTAPv7 example scripts from a v6.2 format database converted <- GTAP_convert(dat_har = "v6_data/gsddat.har", par_har = "v6_data/gsdpar.har", set_har = "v6_data/gsdset.har", target = "GTAPv7") ems_example(model = "GTAPv7", path = "path/to/example/scripts", type = "scripts", dat_input = converted$dat, par_input = converted$par, set_input = converted$set) ## End(Not run)# Retrieve GTAP-RE model files ems_example("GTAP-RE", tempdir()) ## Not run: # The following example requires input data. See # https://teemsphere.github.io/ to get started. # Generate GTAP-RE example scripts ems_example(model = "GTAP-RE", path = "path/to/example/scripts", type = "scripts", dat_input = "v7_data/gsdfdat.har", par_input = "v7_data/gsdfpar.har", set_input = "v7_data/gsdfset.har") # Generate GTAPv7 example scripts from a v6.2 format database converted <- GTAP_convert(dat_har = "v6_data/gsddat.har", par_har = "v6_data/gsdpar.har", set_har = "v6_data/gsdset.har", target = "GTAPv7") ems_example(model = "GTAPv7", path = "path/to/example/scripts", type = "scripts", dat_input = converted$dat, par_input = converted$par, set_input = converted$set) ## End(Not run)
Parses the model and closure files, conducts pre-deployment checks, and carries out specified modifications.
ems_model(model_file, closure_file, var_omit = NULL, ...)ems_model(model_file, closure_file, var_omit = NULL, ...)
model_file |
Character vector length 1, path to a TABLO file with .tab extension. See teems-models for vetted models and compatible Tablo file formatting. |
closure_file |
Character vector length 1, path to a closure file with .cls extension. See teems-models for closure file formatting. |
var_omit |
Character vector of variable length (default
is |
... |
A named pairlist assigning values to model coefficients. Name must match a coefficient declared in the model file. Value may be a length-1 numeric, a data frame or data frame extension (e.g., tibble, data.table), or a path to a CSV file. |
If a length-1 numeric is supplied via ..., this
value is applied uniformly across all tuples for that
coefficient. For heterogeneous values, data frame and CSV
inputs must contain a Value column and one column per set
index using the model-specific naming convention (set name
concatenated with its index letter, e.g., REGr, COMMc).
Inputs are subject to structure checks against the set
aggregations specified in ems_data() and all tuples must
be present.
A tibble comprising parsed model statements to be
passed to the model argument of ems_deploy().
ems_example() for writing teems example models and scripts to file. ems_deploy() for loading the output of this
function as well as conducting closure swaps.
# Simple static model retrieval and load GTAPv7 <- ems_example("GTAPv7", tempdir()) ems_model(GTAPv7[["model_file"]], GTAPv7[["closure_file"]]) # Retrieve intertemporal model GTAP_RE <- ems_example("GTAP-RE", tempdir()) # Construct data frame sectors <- c("crops", "food", "livestock", "mnfcs", "svces") regions <- c("usa", "chn", "row") time_steps <- 0:5 SUBPAR <- expand.grid(COMMc = sectors, REGr = regions, ALLTIMEt = time_steps) SUBPAR$Value <- runif(nrow(SUBPAR)) # Model load with: # 1) variable omission # 2) uniform numeric value applied to KAPPA coefficient # 3) heterogeneous values allocated to SUBPAR via data frame ems_model(model_file = GTAP_RE[["model_file"]], closure_file = GTAP_RE[["closure_file"]], var_omit = c("atall", "avaall", "tfe", "tfm", "tgd", "tgm", "tid", "tim"), KAPPA = 0.03, SUBPAR = SUBPAR)# Simple static model retrieval and load GTAPv7 <- ems_example("GTAPv7", tempdir()) ems_model(GTAPv7[["model_file"]], GTAPv7[["closure_file"]]) # Retrieve intertemporal model GTAP_RE <- ems_example("GTAP-RE", tempdir()) # Construct data frame sectors <- c("crops", "food", "livestock", "mnfcs", "svces") regions <- c("usa", "chn", "row") time_steps <- 0:5 SUBPAR <- expand.grid(COMMc = sectors, REGr = regions, ALLTIMEt = time_steps) SUBPAR$Value <- runif(nrow(SUBPAR)) # Model load with: # 1) variable omission # 2) uniform numeric value applied to KAPPA coefficient # 3) heterogeneous values allocated to SUBPAR via data frame ems_model(model_file = GTAP_RE[["model_file"]], closure_file = GTAP_RE[["closure_file"]], var_omit = c("atall", "avaall", "tfe", "tfm", "tgd", "tgm", "tid", "tim"), KAPPA = 0.03, SUBPAR = SUBPAR)
ems_option_get() returns default package
options. If name is NULL (the default), all option
values are returned as a list.
ems_option_get(name = NULL)ems_option_get(name = NULL)
name |
Name of the option for which to retrieve a value. One of:
|
If name is NULL, a named list of all current
option values. Otherwise, the value of the requested option.
ems_option_set() for setting package options.
ems_option_reset() for resetting package options.
# Retrieve all options values ems_option_get() # Retrieve option value for `ndigits` ems_option_get("ndigits")# Retrieve all options values ems_option_get() # Retrieve option value for `ndigits` ems_option_get("ndigits")
ems_option_reset() resets all package options
to default values.
ems_option_reset()ems_option_reset()
invisible(NULL), called for its side effects.
ems_option_set() for setting package options.
ems_option_get() for retrieving package options.
# Set multiple options ems_option_set(verbose = FALSE, ndigits = 8) # Retrieve modified option value for `verbose` ems_option_get("verbose") # Reset options to default values ems_option_reset() # Retrieve default option value for `verbose` ems_option_get("verbose")# Set multiple options ems_option_set(verbose = FALSE, ndigits = 8) # Retrieve modified option value for `verbose` ems_option_get("verbose") # Reset options to default values ems_option_reset() # Retrieve default option value for `verbose` ems_option_get("verbose")
ems_option_set() allows the user to customize
advanced options.
ems_option_set( verbose = NULL, tempdir = NULL, ndigits = NULL, accuracy_threshold = NULL, check_shock_status = NULL, timestep_header = NULL, n_timestep_header = NULL, full_exclude = NULL, docker_tag = NULL )ems_option_set( verbose = NULL, tempdir = NULL, ndigits = NULL, accuracy_threshold = NULL, check_shock_status = NULL, timestep_header = NULL, n_timestep_header = NULL, full_exclude = NULL, docker_tag = NULL )
verbose |
Logical of length 1 (default is |
tempdir |
A character vector length 1. Default is what is
returned by |
ndigits |
Integer (default is |
accuracy_threshold |
Numeric length 1 (default |
check_shock_status |
Logical of length 1 (default is
|
timestep_header |
A character vector length 1 (default is
|
n_timestep_header |
A character vector length 1 (default
is |
full_exclude |
A character vector of variable length
(default is |
docker_tag |
Character length 1 (default |
invisible(NULL), called for its side effects.
ems_option_get() for retrieving package options.
ems_option_reset() for resetting package options.
# Set multiple options ems_option_set(verbose = FALSE, ndigits = 8) # Retrieve value of `verbose` ems_option_get("verbose") # Reset options to default values ems_option_reset()# Set multiple options ems_option_set(verbose = FALSE, ndigits = 8) # Retrieve value of `verbose` ems_option_get("verbose") # Reset options to default values ems_option_reset()
Prepares heterogeneous absolute-value trajectory
shocks. Inputs are aggregated according to the set mappings
in ems_data() and converted to percentage changes
internally, making scenario shocks portable across
aggregations. All tuples must be present in input at full
pre-aggregation resolution. Partial variable scenario shocks
are not permitted.
See the scenario shocks chapter of the user manual for an illustrative example.
ems_scenario_shock(var, input)ems_scenario_shock(var, input)
var |
Character of length 1, the variable to be shocked. |
input |
Path to a CSV file, or a data frame or data frame
extension (e.g., tibble, data.table). Must contain a |
A list object with shock configuration to be passed
to the shock argument of ems_deploy().
ems_deploy() for loading the output of this
function. ems_swap() for changing the standard model
closure.
Calls the
teems-solver
Docker image to solve the constrained optimization problem.
Runs singularity, accuracy, and error checks on the results
and structures outputs with ems_compose().
ems_solve( cmf_path, solution_method = c("Johansen", "mod_midpoint"), matrix_method = c("LU", "DBBD", "SBBD", "NDBBD"), n_subintervals = 1L, steps = c(2L, 4L, 8L), n_tasks = 1L, laA = 300L, laD = 200L, laDi = 500L, suppress_outputs = FALSE, terminal_run = FALSE, append_args = NULL )ems_solve( cmf_path, solution_method = c("Johansen", "mod_midpoint"), matrix_method = c("LU", "DBBD", "SBBD", "NDBBD"), n_subintervals = 1L, steps = c(2L, 4L, 8L), n_tasks = 1L, laA = 300L, laD = 200L, laDi = 500L, suppress_outputs = FALSE, terminal_run = FALSE, append_args = NULL )
cmf_path |
Character length 1, path to the CMF file
generated by |
solution_method |
The solution method to be used, default
is the one-step
|
matrix_method |
Character of length 1, matrix solution
method (default is
|
n_subintervals |
Integer length 1 (default is |
steps |
Integer length 3 (default is |
n_tasks |
Integer length 1 (default is |
laA |
Integer length 1 (default is |
laD |
Integer length 1 (default is |
laDi |
Integer length 1 (default is |
suppress_outputs |
Logical length 1 (default is |
terminal_run |
Logical length 1 (default is |
append_args |
Character vector (default |
Increase laA, laD, or laDi gradually if the
solver returns "Error return from MA48B/BD because LA is
...". The relevant parameter depends on the matrix_method
in use (see above).
A tibble of model output variables and coefficients.
invisible(NULL) if suppress_outputs = TRUE. Instructions
for terminal execution if terminal_run = TRUE.
ems_deploy() for generating "cmf_path".
solve_in_situ() for calling the solver on existing input
files. ems_compose() for structuring data when
"suppress_outputs" or "terminal_run" is TRUE.
## Not run: # The following examples require the teems solver to be built. # See https://teemsphere.github.io/ to get started. # Solving a static model with Johansen: ems_solve(cmf_path) # Solving a dynamic model with the SBBD method: ems_solve(cmf_path, solution_method = "mod_midpoint", matrix_method = "SBBD", n_tasks = 6) ## End(Not run)## Not run: # The following examples require the teems solver to be built. # See https://teemsphere.github.io/ to get started. # Solving a static model with Johansen: ems_solve(cmf_path) # Solving a dynamic model with the SBBD method: ems_solve(cmf_path, solution_method = "mod_midpoint", matrix_method = "SBBD", n_tasks = 6) ## End(Not run)
Prepares a closure swap for input into the
swap_in or swap_out arguments of ems_deploy().
ems_swap(var, ...)ems_swap(var, ...)
var |
Character of length 1, model variable to swap. |
... |
Optional named arguments restricting the swap to a
subset of variable elements. Each name must use the
model-specific set-index format (set name concatenated with
its index letter, e.g.,
|
ems_swap() return values have no purpose used in
isolation. The closure provided to the closure_file
argument of ems_model() will be used if no swaps are
specified. Note that full variable swaps can be directly
inputted as a character string in the "swap_in" and
"swap_out" arguments of ems_deploy().
Swaps "in" (joining the list of exogenous variables) are
processed prior to swaps out (leaving the list of exogenous
variables), and in the same order as they are loaded into
ems_deploy().
A list of class "full" or "partial" and "single"
or "multi" containing the swap specification. Intended for
use as swap_in or swap_out in ems_deploy().
ems_model() for parsing and modifying model and
closure files. ems_deploy() for loading the output of
this function.
# Full variable swaps ems_swap("tfd") # out ems_swap("qfd") # in # Partial variable swaps with uniform "PROD_COMM" set # application (note distinction between "REGr" and "REGs") in # the classic GTAP model (version 6.2) ems_swap("tfd", TRAD_COMMi = "food", REGr = "chn") # out ems_swap("qfd", TRAD_COMMi = "food", REGs = "chn") # in # Partial variable, multiple element swaps with uniform "ACTS" # set application in the standard GTAP model (version 7.0). ems_swap("tfd", COMMc = c("food", "crops"), REGr = "usa") # out ems_swap("qfd", COMMc = c("food", "crops"), REGr = "usa") # in # Valid subsets may also be selected. ems_swap("txs", COMMc = "NMRG", ALLTIMEt = "FWDTIME") # out ems_swap("qxs", COMMc = "NMRG", ALLTIMEt = "FWDTIME") # in# Full variable swaps ems_swap("tfd") # out ems_swap("qfd") # in # Partial variable swaps with uniform "PROD_COMM" set # application (note distinction between "REGr" and "REGs") in # the classic GTAP model (version 6.2) ems_swap("tfd", TRAD_COMMi = "food", REGr = "chn") # out ems_swap("qfd", TRAD_COMMi = "food", REGs = "chn") # in # Partial variable, multiple element swaps with uniform "ACTS" # set application in the standard GTAP model (version 7.0). ems_swap("tfd", COMMc = c("food", "crops"), REGr = "usa") # out ems_swap("qfd", COMMc = c("food", "crops"), REGr = "usa") # in # Valid subsets may also be selected. ems_swap("txs", COMMc = "NMRG", ALLTIMEt = "FWDTIME") # out ems_swap("qxs", COMMc = "NMRG", ALLTIMEt = "FWDTIME") # in
Prepares a uniform shock to be implemented as a single percentage-change value uniformly across all or a subset of variable tuples.
ems_uniform_shock(var, value, ...)ems_uniform_shock(var, value, ...)
var |
Character of length 1, the variable to be shocked. |
value |
Numeric length 1, percentage-change value of the shock. |
... |
Optional named arguments restricting the shock to a
subset of the variable's elements. Each name must use the
model-specific set-index format (set name concatenated with
its index letter, e.g., |
A list object with shock configuration to be passed
to the shock argument of ems_deploy().
ems_deploy() for loading the output of this
function. ems_swap() for changing the standard model
closure.
# Full uniform: 2% shock imposed on all afeall tuples ems_uniform_shock(var = "afeall", value = 2) # Partial uniform by element: applied only to the "chn" # element in set REGr (REG). Note that set designations must # consist of the concatenation of the standard set (e.g., REG) # and variable-specific index (e.g., r). ems_uniform_shock(var = "afeall", REGr = "chn", value = 2) # Partially uniform by subset and element: applied to "chn" # and "usa" across the MARG and FWDTIME subsets. ems_uniform_shock(var = "qxs", COMMc = "MARG", REGs = c("chn", "usa"), ALLTIMEt = "FWDTIME", value = -1)# Full uniform: 2% shock imposed on all afeall tuples ems_uniform_shock(var = "afeall", value = 2) # Partial uniform by element: applied only to the "chn" # element in set REGr (REG). Note that set designations must # consist of the concatenation of the standard set (e.g., REG) # and variable-specific index (e.g., r). ems_uniform_shock(var = "afeall", REGr = "chn", value = 2) # Partially uniform by subset and element: applied to "chn" # and "usa" across the MARG and FWDTIME subsets. ems_uniform_shock(var = "qxs", COMMc = "MARG", REGs = c("chn", "usa"), ALLTIMEt = "FWDTIME", value = -1)
GTAP_convert() converts GTAP HAR database files
into lists of arrays as well as converts between the classic
v6.2 and standard v7.0 data formats. The output can then be
passed directly to ems_data() via its dat_input,
par_input, and set_input arguments, or written to disk
for later use.
GTAP_convert(dat_har, par_har, set_har, target = NULL)GTAP_convert(dat_har, par_har, set_har, target = NULL)
dat_har |
Character vector of length 1, file name in working directory or path to a GTAP HAR file with basedata coefficient data. |
par_har |
Character vector of length 1, file name in working directory or path to a GTAP HAR file with parameter coefficient data. |
set_har |
Character vector of length 1, file name in working directory or path to a GTAP HAR file with set elements and attributes. |
target |
Character vector of length 1 (default is
|
A named list with elements dat, par, and set,
each containing a list of arrays corresponding to database
headers. Suitable for direct use with ems_data().
ems_data() for loading and preparing converted
data for a model run.
## Not run: # The following examples require input data. See # https://teemsphere.github.io/ to get started. # Convert HAR files to lists of arrays ls_arrays <- GTAP_convert( dat_har = "path/to/gsdfdat.har", par_har = "path/to/gsdfpar.har", set_har = "path/to/gsdfset.har" ) # Convert v7.0 files to v6.2 format converted2v6 <- GTAP_convert( dat_har = "v7_data/gsdfdat.har", par_har = "v7_data/gsdfpar.har", set_har = "v7_data/gsdfset.har", target = "GTAPv6" ) # Convert v6.2 files to v7.0 format converted2v7 <- GTAP_convert( dat_har = "v6_data/gsddat.har", par_har = "v6_data/gsdpar.har", set_har = "v6_data/gsdset.har", target = "GTAPv7" ) ## End(Not run)## Not run: # The following examples require input data. See # https://teemsphere.github.io/ to get started. # Convert HAR files to lists of arrays ls_arrays <- GTAP_convert( dat_har = "path/to/gsdfdat.har", par_har = "path/to/gsdfpar.har", set_har = "path/to/gsdfset.har" ) # Convert v7.0 files to v6.2 format converted2v6 <- GTAP_convert( dat_har = "v7_data/gsdfdat.har", par_har = "v7_data/gsdfpar.har", set_har = "v7_data/gsdfset.har", target = "GTAPv6" ) # Convert v6.2 files to v7.0 format converted2v7 <- GTAP_convert( dat_har = "v6_data/gsddat.har", par_har = "v6_data/gsdpar.har", set_har = "v6_data/gsdset.har", target = "GTAPv7" ) ## End(Not run)
Calls the
teems-solver
Docker image directly with user-supplied input files,
bypassing the ems_data() / ems_model() /
ems_deploy() pipeline. All input files must be provided
in their final form.
solve_in_situ( ..., model_dir, model_file, closure_file, shock_file, solution_method = c("Johansen", "mod_midpoint"), matrix_method = c("LU", "DBBD", "SBBD", "NDBBD"), n_subintervals = 1L, steps = c(2L, 4L, 8L), n_tasks = 1L, laA = 300L, laD = 200L, laDi = 500L, suppress_outputs = FALSE, terminal_run = FALSE, append_args = NULL )solve_in_situ( ..., model_dir, model_file, closure_file, shock_file, solution_method = c("Johansen", "mod_midpoint"), matrix_method = c("LU", "DBBD", "SBBD", "NDBBD"), n_subintervals = 1L, steps = c(2L, 4L, 8L), n_tasks = 1L, laA = 300L, laD = 200L, laDi = 500L, suppress_outputs = FALSE, terminal_run = FALSE, append_args = NULL )
... |
Named arguments corresponding to input files
necessary for an in-situ model run. Names must correspond to
"File" statements within the model Tablo file. Values
correspond to file paths where these files are found. No
checks or modifications are conducted on input files used in
this manner. All model declared input files as well as
|
model_dir |
Character of length 1, base directory where input files will be copied (if not all already present) and model outputs will be written. |
model_file |
Character vector length 1, path to a TABLO file with .tab extension. See teems-models for vetted models and compatible Tablo file formatting. |
closure_file |
Character vector length 1, path to a closure file with .cls extension. See teems-models for closure file formatting. |
shock_file |
A character vector length 1, path to a file with .shf extension representing a fully prepared shock file. No checks or modifications are carried out on this file. |
solution_method |
The solution method to be used, default
is the one-step
|
matrix_method |
Character of length 1, matrix solution
method (default is
|
n_subintervals |
Integer length 1 (default is |
steps |
Integer length 3 (default is |
n_tasks |
Integer length 1 (default is |
laA |
Integer length 1 (default is |
laD |
Integer length 1 (default is |
laDi |
Integer length 1 (default is |
suppress_outputs |
Logical length 1 (default is |
terminal_run |
Logical length 1 (default is |
append_args |
Character vector (default |
A tibble containing model output variables and
coefficients. Alternatively, if "suppress_outputs" is
TRUE, file path to a CMF file that may be used with
ems_compose().
ems_solve() for the standard package-supported
solver.
## Not run: # The following examples require the teems solver to be built. # See https://teemsphere.github.io/ to get started. solve_in_situ( GTAPDATA = "path/to/dat_file.txt", GTAPPARM = "path/to/par_file.txt", GTAPSETS = "path/to/sets_file.txt", model_dir = "existing/dir/for/model_run", model_file = "path/to/model_file.tab", closure_file = "path/to/closure_file.cls", shock_file = "path/to/shock_file.shf" ) ## End(Not run)## Not run: # The following examples require the teems solver to be built. # See https://teemsphere.github.io/ to get started. solve_in_situ( GTAPDATA = "path/to/dat_file.txt", GTAPPARM = "path/to/par_file.txt", GTAPSETS = "path/to/sets_file.txt", model_dir = "existing/dir/for/model_run", model_file = "path/to/model_file.tab", closure_file = "path/to/closure_file.cls", shock_file = "path/to/shock_file.shf" ) ## End(Not run)