View source: R/perfect-foresight.R
| perfect_foresight_nonlinear | R Documentation |
Computes deterministic perfect foresight transition paths for nonlinear
DSGE models using a stacked-time Newton solver (Juillard et al., 1998).
Unlike the linearized perfect_foresight(), this function solves the
full nonlinear equilibrium conditions simultaneously over the entire
horizon, giving exact (up to Newton tolerance) paths even for large shocks.
perfect_foresight_nonlinear(
model,
params,
shock_sd,
shocks = NULL,
initial = NULL,
horizon = 40L,
tol = 1e-08,
max_iter = 50L,
verbose = FALSE
)
model |
A |
params |
Named numeric vector or list of free parameter values. |
shock_sd |
Named numeric vector of shock standard deviations with
names matching |
shocks |
Shock path specification (same interface as
Supports anticipated (news) shocks: because the nonlinear system
is solved simultaneously over the whole horizon under perfect foresight,
agents see the entire future shock path at |
initial |
Named numeric vector of initial DEVIATIONS from steady state for state variables. Defaults to zero (all states start at SS). |
horizon |
Integer. Number of periods to simulate. Default 40. |
tol |
Convergence tolerance (maximum absolute equation residual).
Default |
max_iter |
Maximum Newton iterations. Default 50. |
verbose |
Logical. If |
The algorithm (Juillard et al., 1998) stacks the n \times T nonlinear
equilibrium conditions into a single system and solves it by Newton's method.
The Jacobian is block-bidiagonal (each period's equations depend only on
the current and next-period variables) and is assembled numerically using
forward finite differences. The block structure is exploited via block
back-substitution, giving O(T n^3) cost per Newton step. Armijo
backtracking stabilises convergence for large initial steps.
The initial state x_1 is pinned to steady_state + initial
via equality constraints that replace the state equations at t=1.
For t = T+1 the terminal condition v_{T+1} = \bar{v} (steady
state) is imposed. The solver is warm-started from the linearized
perfect_foresight() path, which is exact for small shocks and
provides a good initial guess for large ones.
A "dsge_perfect_foresight" object with the same fields as
perfect_foresight, so all plot, print, and
summary methods apply unchanged. Three extra fields are appended:
TRUE
Number of Newton iterations taken
Logical; TRUE if max|R| < tol
Juillard, M., Laxton, D., McAdam, P. and Pioro, H. (1998). An algorithm competition: First-order iterations versus Newton-based techniques. Journal of Economic Dynamics and Control, 22, 1291–1318.
perfect_foresight for linearized paths,
dsgenl_model for nonlinear model specification.
rbc <- dsgenl_model(
"1/C = beta / C(+1) * (alpha * exp(Z) * K^(alpha-1) + 1 - delta)",
"K(+1) = exp(Z) * K^alpha - C + (1 - delta) * K",
"Z(+1) = rho * Z",
observed = "C", endo_state = "K", exo_state = "Z",
fixed = list(alpha = 0.33, beta = 0.99, delta = 0.025),
start = list(rho = 0.9)
)
pf <- perfect_foresight_nonlinear(
rbc, params = c(rho = 0.9), shock_sd = c(Z = 0.01),
shocks = list(Z = 0.1), horizon = 40
)
plot(pf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.