View source: R/statistical_tests.R
| estimate_long_run_covariance | R Documentation |
Estimates the long-run covariance matrix using the Newey-West (1987) approach with a Bartlett kernel. Provides Heteroskedasticity and Autocorrelation Consistent (HAC) variance estimates used for studentizing Reality Check test statistics.
estimate_long_run_covariance(loss_differences, block_length)
loss_differences |
A |
block_length |
|
Implements the Newey-West (1987) HAC covariance matrix estimator with Bartlett kernel
weights w_j = 1 - j / (l + 1) for lags j = 1, \ldots, l, where l
denotes the truncation lag (following the notation of Newey & West, 1987, and
Politis & Romano, 1994), here set equal to block_length. This is essential
for accounting for serial dependence in time-series forecast evaluations.
A symmetric positive semi-definite matrix of dimensions
K x K representing the estimated long-run covariance.
Newey, W. K., & West, K. D. (1987). A Simple Positive Semi-Definite Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55(3), 703–708. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/1913610")}
Politis, D. N., & Romano, J. P. (1994). The stationary bootstrap. Journal of the American Statistical Association, 89(428), 1303–1313. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1994.10476870")}
data(metals)
# metals: 165 x 15; columns 1-14 are competing forecasts, column 15 is the benchmark
# A small offset (+0.5) is added to the lagged benchmark to avoid degenerate zero
# loss differences when forecasts equal the realized value exactly (illustration only).
P <- nrow(metals)
K_total <- ncol(metals)
K <- K_total - 1 # 14 competing forecasts
realized <- c(metals[-1, K_total], metals[P, K_total]) + 0.5
benchmark_loss <- (metals[, K_total] - realized)^2
model_loss <- (metals[, 1:K] - realized)^2
loss_diff <- benchmark_loss - model_loss
lrc_result <- estimate_long_run_covariance(loss_diff, block_length = 5)
print(round(lrc_result[1:3, 1:3], 6))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.