R/EstimateMAXSLOPE.R

Defines functions EstimateMAXSLOPE

Documented in EstimateMAXSLOPE

EstimateMAXSLOPE <-
function(curve.x, curve.y) {
  # 
  # Estimates taxon base rate for a MAXSLOPE curve.
  #
  # Args:
  #   curve.x: X values of curve (vector).
  #   curve.y: Y values of curve (vector).  
  #
  # Returns:
  #   Base rate estimate (scalar).
  # 
  n <- length(curve.y)
  my <- max(curve.y)
  my.x <- max(curve.x[curve.y == my])
  my.n <- sum(curve.x >= my.x) - .5 * (sum(curve.y == my) - 1)
  p.estimate <- my.n / n
  return(p.estimate)
}

Try the RTaxometrics package in your browser

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

RTaxometrics documentation built on May 31, 2023, 8:29 p.m.