shock_decomposition: Historical Shock Decomposition

View source: R/smoother.R

shock_decomposition.dsge_solutionR Documentation

Historical Shock Decomposition

Description

Decomposes the observed variables into the contributions of each structural shock. At each time t, the observed deviation from steady state is written as a sum of contributions from current and past shocks plus the initial condition contribution.

Usage

## S3 method for class 'dsge_solution'
shock_decomposition(x, data, ...)

shock_decomposition(x, ...)

## S3 method for class 'dsge_fit'
shock_decomposition(x, ...)

## S3 method for class 'dsge_bayes'
shock_decomposition(x, ...)

Arguments

x

A dsge_fit or dsge_bayes object.

data

Matrix or data frame of observed data with columns matching the model's observable names. Required when x is a dsge_solution.

...

Additional arguments (currently unused).

Details

The state-space solution gives:

x_t = H^t x_0 + \sum_{j=1}^{t} H^{t-j} M \varepsilon_j

The historical decomposition partitions the observed variables y_t = Z x_t into the contribution of each structural shock \varepsilon_j^{(k)} accumulated through the propagation mechanism. The sum of all contributions (including the initial condition term) reproduces the smoothed observables exactly.

Value

An object of class "dsge_decomposition" containing:

decomposition

A 3D array with dimensions [T, n_obs, n_shocks + 1]. The last slice contains the initial condition contribution.

obs_names

Character vector of observed variable names.

shock_names

Character vector of shock names (plus "initial").

observed

T x n_obs matrix of observed data (deviations).

Examples


m <- dsge_model(
  obs(y ~ z),
  state(z ~ rho * z),
  start = list(rho = 0.5)
)
set.seed(1)
e <- rnorm(100)
z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+e[i]
fit <- estimate(m, data = data.frame(y = z))
hd <- shock_decomposition(fit)
plot(hd)



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