Learn R Programming

bayesianOU (version 0.1.3)

evaluate_oos: Evaluate out-of-sample forecast metrics

Description

Computes RMSE and MAE for multiple forecast horizons.

Usage

evaluate_oos(
  summ,
  Yz,
  Xz,
  zTMG,
  T_train,
  COM_ts,
  K_ts,
  com_in_mean = FALSE,
  horizons = c(1, 4, 8)
)

Value

Named list with one element per horizon...

Arguments

summ

List. Posterior summary from extract_posterior_summary

Yz

Numeric matrix. Standardized Y values (T x S)

Xz

Numeric matrix. Standardized X values (T x S)

zTMG

Numeric vector. Standardized TMG series

T_train

Integer. End of training period

COM_ts

Numeric matrix. COM values by time and sector (T x S)

K_ts

Numeric matrix. Capital values by time and sector (T x S)

com_in_mean

Logical. Whether COM is included in mean equation

horizons

Integer vector. Forecast horizons to evaluate

Examples

Run this code
# 1. Generate dummy data for testing
T_obs <- 20
S <- 2
Yz <- matrix(rnorm(T_obs * S), nrow = T_obs, ncol = S)
Xz <- matrix(rnorm(T_obs * S), nrow = T_obs, ncol = S)
COM_ts <- matrix(abs(rnorm(T_obs * S)), nrow = T_obs, ncol = S)
K_ts <- matrix(abs(rnorm(T_obs * S)) + 1, nrow = T_obs, ncol = S)
zTMG <- rnorm(T_obs)

# 2. Create a dummy summary list (mimicking extract_posterior_summary)
summ <- list(
  theta_s = runif(S),
  kappa_s = runif(S),
  a3_s = runif(S),
  beta0_s = runif(S),
  beta1 = 0.5,
  gamma = 0.1
)

# 3. Run the function
metrics <- evaluate_oos(summ, Yz, Xz, zTMG, T_train = 15, 
                        COM_ts, K_ts, horizons = c(1, 2))
print(metrics)

Run the code above in your browser using DataLab