variance_decomposition: Variance Decomposition

View source: R/variance-decomposition.R

variance_decompositionR Documentation

Variance Decomposition

Description

Computes the share of each observable variable's variance attributable to each structural shock.

Usage

variance_decomposition(x, horizon = NULL, ...)

## S3 method for class 'dsge_solution'
variance_decomposition(x, horizon = NULL, ...)

## S3 method for class 'dsge_fit'
variance_decomposition(x, horizon = NULL, ...)

## S3 method for class 'dsge_bayes'
variance_decomposition(x, horizon = NULL, ...)

Arguments

x

A dsge_solution, dsge_fit, or dsge_bayes object.

horizon

NULL (default) for the unconditional decomposition, or an integer vector of horizons for FEVD.

...

Additional arguments (currently unused).

Details

Two flavours are supported, controlled by the horizon argument:

  • Unconditional (default, horizon = NULL): the decomposition of the long-run / steady-state variance. For each shock j, the state covariance contribution \Sigma_x^{(j)} solves the discrete Lyapunov equation \Sigma_x^{(j)} = H \Sigma_x^{(j)} H' + M_j \sigma_j^2 M_j' and the observable variance share is \mathrm{diag}(G \Sigma_x^{(j)} G').

  • Forecast-error variance decomposition (FEVD) (horizon = 1:H): the share of each shock in the h-step-ahead forecast-error variance for a vector of horizons. Forecast-error variance at horizon h is \sum_{k=0}^{h-1} H^k M \Sigma_\varepsilon M' (H^k)'.

Value

An object of class "dsge_variance_decomposition" containing:

contribution

Either a n_o \times n_e matrix (unconditional) or a n_h \times n_o \times n_e array (FEVD) of variance contributions in level units (squared standard deviations).

contribution_pct

Same shape as contribution, but normalised so that each variable's shares across shocks sum to 100 percent.

obs_names

Character vector of observable variable names.

shock_names

Character vector of structural shock names.

horizon

The horizon argument (or Inf for the unconditional case).

type

"unconditional" or "fevd".

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)
)
sol <- 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))
vd  <- variance_decomposition(sol)
print(vd)
plot(vd)

fevd <- variance_decomposition(sol, horizon = c(1, 4, 8, 20))
plot(fevd)



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