R/fitsad.R

fitsad <- function(x, sad=c("bs","gamma","geom","lnorm","ls","mzsm","nbinom","pareto","poilog","power",
                            "powbend", "volkov", "weibull"), ...){ 
  dots <- list(...)
  sad <- match.arg(sad)
  fit <- get(paste("fit", sad, sep=""), mode = "function")
  if(!"trunc" %in% names(dots) && (sad %in% c("poilog", "geom", "nbinom"))) {
    #BUGFIX: some objects (ie, those created with zeroes=T) have some species with 0 individuals
    # we remove those species before fitting to avoid zero-truncated fits throwing an error
    if (sum(x==0) > 0) {
      warning("Removing zeroes from abundance vector")
      x <- x[x > 0]
  }
}
  do.call(fit, c(list(x = x), dots))
}

Try the sads package in your browser

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

sads documentation built on May 2, 2019, 1:56 p.m.