R/SqErr.R

Defines functions SqErr

Documented in SqErr

#' Calculate the squared 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 squared errors
#' @examples
#' data(eurotempforecast)
#' mean(SqErr(rowMeans(ens), obs))
#' @seealso AbsErr, ScoreDiff, SkillScore
#' @export

SqErr <- function(fcst, obs) {

  # calculate squared difference between forecasts and observations
  sq.err <- (fcst - obs) ^ 2

  # return 
  return(sq.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.