View source: R/dynare-perfect-foresight.R
| simulate_perfect_foresight | R Documentation |
Solves the model's deterministic path exactly as Dynare's
perfect_foresight_setup + perfect_foresight_solver (or simul) do,
using the file's initval, endval, histval and steady statements
and its deterministic shocks (with periods/values), and
complementarity conditions from mcp equation tags (Dynare's lmmcp
option, e.g. a zero lower bound).
simulate_perfect_foresight(
x,
periods = NULL,
shocks = NULL,
params = NULL,
lmmcp = NULL,
tol = 1e-10,
max_iter = 100L
)
x |
A model imported with |
periods |
Number of simulation periods. Defaults to the file's
|
shocks |
Optional matrix (or data frame) of exogenous values by period (rows 1, 2, ...) with columns named after shocks, replacing the file's deterministic shocks for those shocks. |
params |
Optional named parameter values overriding the calibration. |
lmmcp |
Logical: treat equations tagged |
tol |
Convergence tolerance on the largest equation residual. |
max_iter |
Maximum number of Newton iterations. |
An object of class "dsge_dynare_pf": a list with path (a
matrix of the endogenous variables, one row per period from the
initial condition(s) to the terminal one(s), as Dynare's
oo_.endo_simul transposed), exo (the exogenous path, as
oo_.exo_simul), periods, initial and terminal (steady states
or initial/terminal values), converged, iterations and
max_residual.
m <- read_dynare(text = "
var c k;
varexo a;
parameters alpha beta delta;
alpha = 0.33; beta = 0.99; delta = 0.025;
model;
1/c = beta/c(+1) * (alpha * exp(a(+1)) * k^(alpha - 1) + 1 - delta);
k = exp(a) * k(-1)^alpha + (1 - delta) * k(-1) - c;
end;
initval; a = 0; k = 30; c = 2.3; end;
steady;
endval; a = 0.1; end;
steady;
perfect_foresight_setup(periods = 100);
perfect_foresight_solver;
")
pf <- simulate_perfect_foresight(m)
head(pf$path)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.