irf_match: Impulse-Response Matching Estimation

View source: R/irf-match.R

irf_matchR Documentation

Impulse-Response Matching Estimation

Description

Estimates the free parameters of a linear DSGE model by minimising the weighted squared distance between the model's impulse responses and a user-supplied target (e.g. impulse responses estimated from a VAR or local projections).

Usage

irf_match(
  model,
  params_start,
  shock_sd_start,
  target,
  shock_sd_fixed = NULL,
  weight = NULL,
  lower = NULL,
  upper = NULL,
  method = "Nelder-Mead",
  control = list(),
  penalty = 1e+10
)

Arguments

model

A dsge_model object.

params_start

Named numeric vector of starting values for the structural parameters to estimate.

shock_sd_start

Named numeric vector of starting values for the shock standard deviations to estimate. Pass an empty vector (c()) to fix all shock SDs at the values given in shock_sd_fixed.

target

A data frame with columns impulse, response, period and value giving the empirical / target impulse responses to match. Each row is a single (impulse, response, period) datum. Use the same names that the model uses for shocks and variables. The format matches what irf()$data returns, so a reference solution's IRF can be passed directly.

shock_sd_fixed

Named numeric vector of shock SDs to keep fixed while estimating. Their values come from this argument. The full vector passed to solve_dsge() is the union of shock_sd_start (estimated) and shock_sd_fixed.

weight

Optional N \times N positive-definite weighting matrix where N is the number of rows in target. If NULL (default), the identity is used (equally-weighted distance).

lower, upper

Numeric vectors of bounds (length = length(params_start) + length(shock_sd_start)). Default -Inf / Inf.

method

Optimisation method for optim. Default "Nelder-Mead". Use "L-BFGS-B" for box constraints.

control

List of control arguments for optim.

penalty

Penalty value returned when the candidate parameters yield an unstable / non-existent solution. Default 1e10.

Details

The objective stacks all (impulse, response, period) rows of target into a vector and computes

(\text{irf}_\text{model}(\theta) - \text{irf}_\text{target})^\top W (\text{irf}_\text{model}(\theta) - \text{irf}_\text{target}).

If the candidate parameters make the model unstable or fail to solve, penalty is returned (effectively rejecting that vector).

The asymptotic variance of the IRF-matching estimator is

(J' W J)^{-1} J' W \Omega W' J (J' W J)^{-1}

where J is the Jacobian of model IRFs at the optimum and \Omega is the variance of the target IRFs. Computing this efficiently requires user knowledge of \Omega; this function returns the point estimates only.

Value

An object of class "dsge_irf_match" containing:

params

Estimated structural parameter values.

shock_sd

Estimated shock standard deviations.

objective

Achieved minimum objective value.

converged

Logical (optim convergence == 0).

n_iter

Iteration counts returned by optim.

target

The supplied target IRF data frame, augmented with the model-implied fitted values at the optimum (column fitted).

solution

The dsge_solution at the optimum.

References

Christiano, L.J., Eichenbaum, M. and Evans, C.L. (1999). Monetary policy shocks: What have we learned and to what end? In Handbook of Macroeconomics, Volume 1A, ch. 2.

Examples


nk <- dsge_model(
  obs(p   ~ beta * lead(p) + kappa * x),
  unobs(x ~ lead(x) - (r - lead(p) - g)),
  obs(r   ~ psi * p + u),
  state(u ~ rhou * u),
  state(g ~ rhog * g),
  fixed = list(beta = 0.99),
  start = list(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9)
)

# Build a target IRF from a "true" parameterisation
sol_true <- solve_dsge(nk,
  params   = c(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9),
  shock_sd = c(e.u = 1.0, e.g = 0.5))
target_df <- irf(sol_true, periods = 12)$data

# Estimate, starting away from the truth
est <- irf_match(nk,
  params_start   = c(kappa = 0.2, psi = 2.0, rhou = 0.5, rhog = 0.5),
  shock_sd_start = c(e.u = 1.0, e.g = 1.0),
  target         = target_df)
print(est)



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