View source: R/variance-decomposition.R
| variance_decomposition | R Documentation |
Computes the share of each observable variable's variance attributable to each structural shock.
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, ...)
x |
A |
horizon |
|
... |
Additional arguments (currently unused). |
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)'.
An object of class "dsge_variance_decomposition"
containing:
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).
Same shape as contribution, but
normalised so that each variable's shares across shocks sum to
100 percent.
Character vector of observable variable names.
Character vector of structural shock names.
The horizon argument (or Inf for the
unconditional case).
"unconditional" or "fevd".
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.