R/mk_s.R

Defines functions mk_s

Documented in mk_s

#' Mann Kendall S statistic
#'
#' Calculates the MK S statistic. Internal function used in mk_z_stat.
#'
#' @param x time series
#' @return Mann-Kendall's S statistic
#' @export mk_s
#'
mk_s<- function(x){
  n<- length(x)
  S0_fn<- function (i,x) -sign(x[1:(n-i)] - x[(i+1):n])
  sum(unlist(lapply(1:(n-1),S0_fn,x)))
}
vroni-g/change_point_detection documentation built on Dec. 23, 2021, 4:12 p.m.