Skip to contents

Computes the forecast error variance decomposition (FEVD) showing the proportion of forecast error variance of each variable attributable to each structural shock identified via Cholesky decomposition.

Usage

fevd_chol(chol_irf, shock = 0L)

Arguments

chol_irf

N x N x (horizon+1) cube of Cholesky impulse response functions from fcholeskyIRF. Each slice chol_irf[,,h] contains the responses at horizon h. The horizon is automatically inferred from the cube dimensions.

shock

Integer (1-indexed). If provided, returns only the N x horizon matrix for that specific shock (matching MATLAB variance_decomp(irf, shock)). If 0 (default), returns the full N x N x horizon cube for all shocks.

Value

A list containing:

fevd

If shock = 0: N x N x horizon cube where fevd[i,j,h] is the share of forecast error variance of variable i at horizon h explained by shock j. If shock > 0: N x horizon matrix for the specified shock.

Details

The forecast error variance decomposition measures the proportion of the h-step ahead forecast error variance of variable i that is attributable to each structural shock j. For Cholesky-identified VARs:

$$FEVD(i,j,h) = \frac{\sum_{s=0}^{h} [\Psi_s P]_{ij}^2}{\sum_{k=1}^{N} \sum_{s=0}^{h} [\Psi_s P]_{ik}^2}$$

Examples

if (FALSE) { # \dontrun{
# Estimate VAR
var_result <- fVAR(y, p = 2, c = 1)
wold <- fwoldIRF(var_result, horizon = 20)
S <- t(chol(var_result$sigma_full))
chol_irf <- fcholeskyIRF(wold, S)

# Full decomposition (all shocks) — returns 3D cube
vardec <- fevd_chol(chol_irf)

# Single shock decomposition — returns N x horizon matrix
shock <- match("UNCERT", colnames(y))
vardec <- fevd_chol(chol_irf, shock = shock)
} # }