R/kendall_S.R

Defines functions kendall_S

Documented in kendall_S

#' Calculate S statistic for Kendall correlation with time (+1 for concordance, -1 for discordance)
#' 
#' @param x numeric, a time series
#' @return number of concordances minus number of discordances
#' 
#' @author Ken Butler, \email{butler@utsc.utoronto.ca}
#' 
#' @examples
#' 
#' kendall_S(c(2,3,5,4))
#' 
#' @export
#' 
kendall_S <-
function(x) {
  m=outer(x,x,"-")
  sum(sign(m)*lower.tri(m))
}
nxskok/mkac documentation built on June 28, 2021, 5:26 a.m.