Learn R Programming

valueprhr (version 0.1.0)

leave_one_sector_out: Leave-One-Sector-Out Cross-Validation

Description

Performs LOSO CV, leaving out each sector in turn as the test set.

Usage

leave_one_sector_out(panel_data, verbose = TRUE)

Value

A data frame with RMSE and MAE for each held-out sector.

Arguments

panel_data

Data frame in panel format.

verbose

Logical. Print progress. Default TRUE.

Examples

Run this code
# \donttest{
if (requireNamespace("plm", quietly = TRUE)) {
  set.seed(123)
  panel <- data.frame(
    year = rep(2000:2019, 5),
    sector = rep(LETTERS[1:5], each = 20),
    log_direct = rnorm(100, 5, 0.5),
    log_production = rnorm(100, 5, 0.5)
  )
  panel$log_production <- panel$log_direct * 0.95 + rnorm(100, 0, 0.1)

  loso_results <- leave_one_sector_out(panel)
  print(loso_results)
}
# }

Run the code above in your browser using DataLab