R/upward_steepness.R

Defines functions upward_steepness

Documented in upward_steepness

#' proportion of interactions against the rank order
#'
#' @param mat square interaction matrix
#'
#' @return numeric value of upward steepness
#' @importFrom EloRating DS
#' @export
#' @examples
#' data(bonobos, package ="EloRating")
#' upward_steepness(bonobos)

upward_steepness <- function(mat) {
  # determine order based on DS
  xorder <- DS(mat)$ID
  # reorder matrix
  mat <- mat[xorder, xorder]
  # prop of interactions below diag (after reorderding)
  1 - sum(mat[lower.tri(mat)]) / sum(mat)
}

Try the EloSteepness package in your browser

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

EloSteepness documentation built on Sept. 21, 2023, 1:06 a.m.