R/ZZ_forecasting_model.R

Defines functions competition_error

#' Forecasting competition Evaluation
#'
#' @param estimate Matrix of forecast (matrix of 24x30)
#'
#' @returns MSE for competition
#'
#' @noRd
#' @keywords internal
competition_error <- function(estimate) {
  urlfile <- paste0(
    "https://raw.githubusercontent.com/jrvanderdoes/fChange",
    "/main/vignettes/articles/functionaldata/practice.csv"
  )
  data_true <- utils::read.csv(urlfile)[, -1]

  if (is.dfts(estimate)) estimate <- estimate$data

  error <- rep(NA, 14)
  for (i in 1:14) {
    error[i] <- sum((estimate[, i] - data_true[, i])^2)
  }

  mean(error)
}

Try the fChange package in your browser

Any scripts or data that you put into this service are public.

fChange documentation built on June 21, 2025, 9:08 a.m.