Skip to contents

Decomposes a chosen variable's realisation into contributions from each structural shock, identified via a lower-triangular Cholesky factor K. Mirrors the MATLAB hist_decmp(y, beta, residuals, c, p, K, series).

Usage

fhistdec(y, fVAR, K, series)

Arguments

y

TxN numeric matrix of original (undemeaned) data.

fVAR

List returned by fVAR(), containing at minimum beta, residuals, sigma_full, p, c, and n_exog.

K

NxN lower-triangular Cholesky factor of the residual covariance matrix (i.e. t(chol(sigma_full))).

series

Integer (1-indexed) selecting which variable to decompose.

Value

A list with two elements:

histdec

(T-p) x N numeric matrix. Column j is the cumulative contribution of structural shock j to the chosen variable at each point in time.

ystar

(T-p) numeric vector of the demeaned realisation of the chosen variable (benchmark series for the plot).

Details

The structural shocks are recovered as $$\varepsilon_t = K^{-1} u_t$$ where \(u_t\) are the reduced-form residuals. The structural MA representation is built by multiplying each Wold matrix by K: $$\Theta_h = \Psi_h K$$ The contribution of shock \(j\) to variable \(i\) at time \(t\) is then the inner product of \(\Theta_{0:t}[i,j]\) with the time-reversed structural shocks \(\varepsilon_{t:-1:0,j}\): $$HD(t,j) = \sum_{h=0}^{t} \Theta_h[i,j]\, \varepsilon_{t-h,j}$$

See also

fVAR, fcholeskyIRF, fwoldIRF, plothistdec

Examples

if (FALSE) { # \dontrun{
var_result <- fVAR(y, p = 12, c = 1)
K <- t(chol(var_result$sigma_full))
series <- match("UNCERT", colnames(y))

hd <- fhistdec(y, var_result, K, series)

# hd$histdec is (T-p) x N; hd$ystar is the demeaned series
matplot(hd$histdec, type = "l")
lines(hd$ystar, lwd = 2)
} # }