R/AbsErr.R

Defines functions AbsErr

Documented in AbsErr

#' Calculate the absolute error between forecast and observation
#'
#' @param fcst a N-vector representing N time instances of real-valued forecasts
#' @param obs a N-vector representing N time instances of real-valued observations
#' @return numeric N-vector of absolute errors |fcst - obs|
#' @examples
#' data(eurotempforecast)
#' mean(AbsErr(rowMeans(ens), obs))
#' @seealso SqErr, ScoreDiff, SkillScore
#' @export

AbsErr <- function(fcst, obs) {

  # calculate absolute difference between forecasts and observations
  abs.err <- abs(fcst - obs)

  # return 
  return(abs.err)

}

Try the SpecsVerification package in your browser

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

SpecsVerification documentation built on March 26, 2020, 7:55 p.m.