Description Usage Arguments Value Examples
View source: R/class_model_ss.R
The get_residuals
function allows to check the residuals of the steady-state (equilibrium) equations of a dynamic (static) model
and identify equations with the largest errors. This may help to assign initial values to the model's variables more accurately
when the solver cannot find the steady state (equilibrium).
1 | get_residuals(model, largest = 5, calibration = TRUE)
|
model |
an object of |
largest |
the number of equations with the largest errors which are to be printed. |
calibration |
if FALSE, calibrating equations will not be taken into account when computing equations' residuals. Initial values of calibrated parameters will be then treated as their values. |
The function returns a list of two elements: initial
and final
.
Initial residuals are steady-state (equilibrium) equations' residuals computed using the initial values of variables.
Final residuals are residuals computed after the solver has exited.
The function prints the indices of equations with the largest initial and final errors.
The equations can be further investigated using the list_eq
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # copy the example to the current working directory
file.copy(from = file.path(system.file("examples", package = "gEcon"),
"home_production_templ.gcn"), to = getwd())
# make and load the model
home_prod_templ <- make_model("home_production_templ.gcn")
# for the purpose of the example, initial values are set very far from the solution
home_prod_templ <- initval_var(home_prod_templ, c(N = 0.02,
N__H = 0.01,
N__M = 0.01))
home_prod_templ <- steady_state(home_prod_templ)
get_residuals(home_prod_templ)
# after setting more reasonable values the steady state is found
home_prod_templ <- initval_var(home_prod_templ, c(N = 0.5,
N__H = 0.25,
N__M = 0.25))
home_prod_templ <- steady_state(home_prod_templ)
get_residuals(home_prod_templ)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.