perfect_foresight_expect_err: Perfect Foresight Simulation with Expectation Errors

View source: R/perfect-foresight-expecterr.R

perfect_foresight_expect_errR Documentation

Perfect Foresight Simulation with Expectation Errors

Description

Generalises perfect_foresight by allowing the realised shock path to differ from the path agents anticipate at each point in time. In standard perfect foresight, agents at t = 1 see every future shock; in the with-expectation-errors variant, agents form subjective expectations at each period k, solve the residual perfect-foresight problem, then nature delivers the actual one-period shock (which may be a surprise).

Usage

perfect_foresight_expect_err(
  x,
  actual_shocks,
  expected_shocks = NULL,
  initial = NULL,
  horizon = 40L
)

Arguments

x

A dsge_solution object.

actual_shocks

Named list (or matrix) describing the realised shock path – same format as the shocks argument of perfect_foresight.

expected_shocks

Optional named list (or matrix) describing what agents expect at t = 1. Default NULL meaning agents expect no further shocks beyond those already realised. When agents expect the same path that actually materialises, this function reproduces perfect_foresight().

initial

Optional named numeric vector of initial state deviations.

horizon

Integer. Number of periods. Default 40.

Details

This is the analogue of Dynare's perfect_foresight_with_expectation_errors_solver command. A typical use case: study how the economy reacts to a sequence of news/MIT shocks that arrive unexpectedly even though each shock, once it lands, is treated as fully credible going forward.

Value

An object of class c("dsge_perfect_foresight_expecterr", "dsge_perfect_foresight") containing the same fields as perfect_foresight plus an extra element expectation_paths – a list of per-period subjective forecast paths (one matrix per starting period) so users can inspect how agent expectations evolved.

See Also

perfect_foresight (no expectation errors), perfect_foresight_nonlinear.

Examples


m <- dsge_model(
  obs(y ~ beta * lead(y) + 0.1 * x),
  state(x ~ 0.9 * x),
  fixed = list(beta = 0.99))
sol <- solve_dsge(m, params = c(), shock_sd = c(x = 1))
# Agents expect no shocks; nature delivers a one-time shock at t = 5
pf <- perfect_foresight_expect_err(sol,
  actual_shocks = list(x = c(0, 0, 0, 0, 1)),
  horizon = 30)
plot(pf)



dsge documentation built on Sept. 25, 2026, 5:08 p.m.