R/regr_srho.R

Defines functions srho

Documented in srho

#' @title Spearman's rho
#'
#' @details
#' Spearman's rho is defined as Spearman's rank correlation coefficient between truth and response.
#' Calls [stats::cor()] with `method` set to `"spearman"`.
#'
#' @templateVar mid srho
#' @template regr_template
#'
#' @references
#' `r format_bib("rosset_2006")`
#'
#' @inheritParams regr_params
#' @template regr_example
#' @export
srho = function(truth, response, ...) {
  assert_regr(truth, response = response)
  cor(truth, response, method = "spearman")
}

#' @include measures.R
add_measure(srho, "Spearman's rho", "regr", -1, 1, FALSE)

Try the mlr3measures package in your browser

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

mlr3measures documentation built on Aug. 5, 2022, 5:22 p.m.