Computes the forecast error variance decomposition (FEVD) for instrumental variable identified structural shocks. The function scales shocks to unit variance and calculates the contribution of a specific shock to the forecast error variance of each variable over time.
Arguments
- s
N x 1 vector of structural impact coefficients
- S
N x N lower triangular Cholesky factor of the residual covariance matrix
- wold
N x N x (hor+1) cube of Wold impulse response functions
- N
Integer number of variables in the VAR system
- hor
Integer maximum forecast horizon
- sigma
N x N residual covariance matrix
- u
(T-p) x N matrix of VAR residuals
- T1
Integer effective sample size (T-p)
- p
Integer lag order of the VAR model
Value
A list containing: - scaler: N x 1 vector of scaling factors for unit variance normalization - ivirf_scaled: N x (hor+1) matrix of unit variance impulse responses - oil_news_unit_var: 1 x T1 vector of unit variance shock series - check_uv: Scalar variance check (should be close to 1) - denom: N x (hor+1) matrix of total forecast error variances - fevd_iv: N x (hor+1) matrix of FEVD shares (between 0 and 1)
Details
The FEVD measures the proportion of the h-step ahead forecast error variance of each variable that is attributable to the identified structural shock.
The function performs the following steps: 1. Normalizes the structural shock to have unit variance 2. Computes unit variance impulse responses 3. Recovers the unit variance shock series 4. Computes total forecast error variance at each horizon 5. Computes variance due to identified shock 6. Calculates FEVD as the ratio
The FEVD values are proportions between 0 and 1, where higher values indicate that the identified shock explains a larger share of the forecast error variance.
Examples
if (FALSE) { # \dontrun{
# Estimate VAR and compute Wold IRF
var_result <- fVAR(y, p = 2, c = 1)
wold <- fwoldIRF(var_result, horizon = 20)
# IV identification
s <- c(1, 0.5, 0.3)
sigma <- var_result$sigma_full
S <- t(chol(sigma))
# Compute FEVD
result <- fevd_iv(s, S, wold, N = 3, hor = 20,
sigma = sigma, u = var_result$residuals,
T1 = nrow(var_result$residuals), p = 2)
# Plot FEVD for first variable
plot(result$fevd_iv[1, ], type = "l", ylim = c(0, 1),
main = "FEVD: Share of Variance Explained by Shock",
xlab = "Horizon", ylab = "Share")
} # }
