View source: R/perfect-foresight.R
| perfect_foresight | R Documentation |
Simulate deterministic transition paths for DSGE models under perfect foresight. Supports temporary shocks, permanent shocks, and initial condition experiments using the linearized solution.
perfect_foresight(
x,
shocks = NULL,
initial = NULL,
horizon = 40L,
params = NULL,
shock_sd = NULL,
in_sd = FALSE
)
x |
A solved DSGE model object. Can be a |
shocks |
Deterministic shock specification. Can be:
Shock values are in units of the shock variable (not standard deviations).
If Multi-period shock paths. A non-scalar vector specifies a
sequence of shocks hitting at successive periods, e.g.
|
initial |
Named numeric vector of initial state deviations from steady
state. Names must match state variable names. Unspecified states default
to zero. Default is |
horizon |
Integer. Number of periods to simulate. Default 40. |
params |
Named numeric vector of parameters. Required only when
|
shock_sd |
Named numeric vector of shock standard deviations. Used
only when |
in_sd |
Logical. If |
The deterministic transition path is computed using the linearized state-space representation:
x_{t+1} = H x_t + M \varepsilon_{t+1}
y_t = G x_t
where x_t are state deviations from steady state, y_t are
control deviations, and \varepsilon_t are deterministic shocks.
This uses the first-order linearized solution, so results are approximate for large shocks. For small to moderate shocks, the linearized paths are accurate.
An object of class "dsge_perfect_foresight" containing:
Matrix (horizon x n_states) of state deviations from SS
Matrix (horizon x n_controls) of control deviations
Matrix of state levels (SS + deviation), if SS available
Matrix of control levels, if SS available
Named numeric vector of steady-state values
Matrix (horizon x n_shocks) of applied shocks
Named vector of initial state deviations
Integer horizon
Character vector of state names
Character vector of control names
Character vector of shock names
State transition matrix used
Policy matrix used
Shock impact matrix used
# Simple AR(1) model
mod <- dsge_model(
obs(p ~ x),
state(x ~ rho * x),
start = list(rho = 0.9)
)
sol <- solve_dsge(mod, params = list(rho = 0.9), shock_sd = c(x = 0.01))
# One-time shock at period 1
pf <- perfect_foresight(sol, shocks = list(x = 0.01), horizon = 40)
plot(pf)
# Displaced initial condition
pf2 <- perfect_foresight(sol, initial = c(x = 0.05), horizon = 40)
plot(pf2)
# Anticipated (news) shock: known at t=1, hits at t=5
pf3 <- perfect_foresight(sol,
shocks = list(x = c(0, 0, 0, 0, 0.01)),
horizon = 40)
plot(pf3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.