compute_klic: Compute Kullback-Leibler Information Criterion (KLIC)...

View source: R/analysis_helpers.R

compute_klicR Documentation

Compute Kullback-Leibler Information Criterion (KLIC) Negative Log-Likelihood Scores

Description

Computes the per-period Negative Log-Likelihood Score (NLS) loss matrix under a Gaussian predictive density assumption. The NLS is the loss function corresponding to minimisation of the Kullback-Leibler Information Criterion (KLIC) distance from the true density (Corradi & Swanson, 2006).

Usage

compute_klic(
  forecast_matrix,
  forecast_sd_models,
  benchmark_col = ncol(forecast_matrix)
)

Arguments

forecast_matrix

matrix of dimension P x K_total. The benchmark column supplies the realized values y_t.

forecast_sd_models

matrix of dimension P x (K_total - 1), containing time-varying forecast standard deviations, typically from estimate_forecast_variance.

benchmark_col

Index or name of the benchmark column. Defaults to the last column.

Details

For each competing forecast k and period t:

NLS_{t,k} = -\log \phi(y_t \mid \hat{y}_{t,k},\, \hat{\sigma}_{t,k})

where \phi denotes the Gaussian density, y_t is the realized value, \hat{y}_{t,k} is the point forecast, and \hat{\sigma}_{t,k} is the forecast standard deviation. Minimising the average NLS is equivalent to minimising the KLIC distance between the forecast's predictive density and the true density (Corradi & Swanson, 2006). Lower NLS values are better. The benchmark column in the returned matrix is set to zero.

Value

matrix of dimension P x K_total containing NLS values. Lower values indicate better density forecast accuracy. The benchmark column is set to zero.

References

Corradi, V., & Swanson, N. R. (2006). Predictive density and conditional confidence interval accuracy tests. Journal of Econometrics, 135(1–2), 187–228. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jeconom.2005.07.026")}

Corradi, V., & Swanson, N. R. (2011). The White Reality Check and some of its recent extensions. In Festschrift in honor of Halbert L. White.

See Also

kullback_leibler_test, estimate_forecast_variance

Examples

data(metals)
benchmark_col      <- 15
K_total            <- ncol(metals)
comp_cols          <- setdiff(seq_len(K_total), benchmark_col)
forecast_variance  <- estimate_forecast_variance(metals,
                        benchmark_col = benchmark_col)
forecast_sd_models <- sqrt(forecast_variance[, comp_cols])
klic_loss <- compute_klic(metals, forecast_sd_models,
                          benchmark_col = benchmark_col)
head(klic_loss)

RCtest documentation built on June 2, 2026, 9:07 a.m.

Related to compute_klic in RCtest...