13 Solving the model
13.1 Overview
ems_solve() solves the constrained optimization problem according to a range of runtime configuration options. In order to solve, a teems Docker image must be prebuilt. Singularity, accuracy, and error checks are carried out following a successful run. By default, solver outputs are automatically parsed into structured R objects via ems_compose().
13.2 Arguments
| Argument | Default | Description |
|---|---|---|
cmf_path |
NULL |
Path to the CMF file generated by ems_deploy() |
n_tasks |
1L |
Number of tasks to run in parallel. Must be 1L if matrix_method is "LU" |
n_subintervals |
1L |
Number of subintervals for the applied shock. More subintervals may alleviate accuracy issues stemming from large shock magnitudes |
matrix_method |
"LU" |
Matrix solution method (see below) |
solution_method |
"Johansen" |
Solution method (see below) |
steps |
c(2L, 4L, 8L) |
Vector of steps for the modified midpoint method. Must be all odd or all even, length 3 |
laA |
300L |
Memory parameter (%) for "LU" and "SBBD" methods |
laD |
200L |
Memory parameter (%) for "DBBD" and "NDBBD" methods |
laDi |
500L |
Memory parameter (%) for "NDBBD" method |
terminal_run |
FALSE |
When TRUE, exits without running the solver, allowing the user to close R and run from the terminal |
suppress_outputs |
FALSE |
When TRUE, solver outputs are not automatically parsed with ems_compose() |
13.3 Basic usage
outputs <- ems_solve(
cmf_path = cmf_path,
matrix_method = "LU",
solution_method = "Johansen"
)13.4 Matrix methods
| Method | Description |
|---|---|
"LU" |
Standard LU decomposition. The most robust and potentially slowest for large models. n_tasks must be 1L. Works with both static and dynamic models |
"DBBD" |
Doubly bordered block diagonal. Parallel solution method for static models. Potentially faster than "LU" although less robust |
"SBBD" |
Singly bordered block diagonal. Parallel solution method for intertemporal models. Potentially faster than "LU" although less robust |
"NDBBD" |
Nested doubly bordered block diagonal. Parallel solution method for large intertemporal models with many timesteps |
13.5 Solution methods
| Method | Description |
|---|---|
"Johansen" |
Fast one-step approximation. Should only be used as a rough approximation due to handling of nonlinear equations. See COPS manual |
"mod_midpoint" |
Modified midpoint method that performs multiple passes for improved accuracy. The steps parameter controls the number of passes. See COPS manual |
13.6 Memory parameters
If the solver returns “Error return from MA48B/BD because LA is …”, increase the relevant memory parameter gradually:
laAapplies to"LU"and"SBBD"methodslaDapplies to"DBBD"and"NDBBD"methodslaDiapplies to the"NDBBD"method only
outputs <- ems_solve(
cmf_path = cmf_path,
matrix_method = "LU",
solution_method = "Johansen",
laA = 500L
)13.7 Parallel solving
For models that support parallel matrix methods, increase n_tasks:
outputs <- ems_solve(
cmf_path = cmf_path,
n_tasks = 4L,
matrix_method = "SBBD",
solution_method = "Johansen"
)13.8 Multi-step solution
For greater accuracy, use the modified midpoint method with subintervals:
outputs <- ems_solve(
cmf_path = cmf_path,
n_subintervals = 3L,
matrix_method = "LU",
solution_method = "mod_midpoint",
steps = c(2L, 4L, 8L)
)13.9 Terminal mode
For long-running models, terminal_run allows the user to close any R IDE prior to running from the terminal:
ems_solve(
cmf_path = cmf_path,
matrix_method = "LU",
solution_method = "Johansen",
terminal_run = TRUE
)