eval_performance: Evaluate Interpolation Performance of a Single Time Series

View source: R/eval_performance.R

eval_performanceR Documentation

Evaluate Interpolation Performance of a Single Time Series

Description

Subroutine of performance(). Function to define and store performance criteria for the comparison of a single interpolated series with its original. Vectors must be conforming in value, except at indices where missing observations have been interpolated.

Usage

eval_performance(x, X, gappyx, custom = NULL)

Arguments

x

numeric; The original time series vector.

X

numeric; The interpolated time series vector.

gappyx

numeric; The gappy time series vector. Gaps must be indicated by NA.

custom

character; A vector of names of user-defined functions used to calculate custom performance metrics (see details)

Details

The following is a description of the list of base performance metrics included in the returned object:

ID Criterion Optimal
...... ........... .........
1 pearson_r max
2 r_squared max
3 AD min
4 MBE min
5 ME min
6 MAE min
7 MRE min
8 MARE min
9 MAPE min
10 SSE min
11 MSE min
12 RMS min
13 NMSE min
14 RE max
15 RMSE min
16 NRMSD min
17 RMSS min
18 MdAPE min

Users can define and pass-in their own custom performance metric functions, but must adhere to the following rules:

  • Inputs are limited to *ONLY* x (lowercase; the original time series) and X (uppercase; the interpolated time series)

  • Output must be a single numeric value

Examples

 # User-defined functions to calculate a custom performance metric (see Details for rules)
 
 my_metric1 <- function(x,X){
 
  # Sum of original + interpolated values
  
  val <- x + X
  
  return(val) # return value must be a single numeric element
  
  }
  
 my_metric2 <- function(x,X){
 
  # Sum of index positions of interpolated values
 
  val <- sum(which(x != X))
 
  return(val) # return value must be a single numeric element
 
 } 
 
 # Implementing in eval_performance()
 
 eval_performance(x = x, X = X, gappyx = gappyx, custom = c("my_metric1", "my_metric2"))
 



castels/interpTools documentation built on June 7, 2024, 4:20 p.m.