R/02_calculate_tem.R

Defines functions calculate_tem

Documented in calculate_tem

#'
#' Calculate technical error of measurement (TEM)
#'
#' Function to calculate **technical error of measurement (TEM)** based on
#' formula created by *Ulijaszek and Kerr (1999)* as an indicator of measurement
#' precision as described by *Mueller and Mortorell (1998)*. This function is
#' specific for intra-observer TEM for two measurements, and for inter-observer
#' TEM involving two measurers.
#'
#' @param d Numeric vector of difference between two measurements made by same
#'     measurer or between two measurers.
#' @param n Numeric value of number of individuals measured.
#'
#' @return A numeric value of the technical error of measurement (TEM). Unit
#'     of TEM is the same as the unit of the measurements compared.
#'
#' @examples
#' ## Apply calculate_tem to smartStd dataset to get TEM for weight for
#' ## supervisor
#' x <- smartStd[smartStd$observer == 0, ]
#' difference <- x$weight1 - x$weight2
#' tem <- calculate_tem(d = difference, n = length(difference))
#' tem
#'
#' @export
#'

calculate_tem <- function(d, n) {
  ## TEM formula
  tem <- sqrt(sum(d ^ 2) / (2 * n))

  ## Return output
  tem
}
nutriverse/anthrocheckr documentation built on April 14, 2024, 8:38 p.m.