R/GammaModes.R

Defines functions GammaModes

Documented in GammaModes

#' @title Modes of the Gamma distribution
#' 
#' @description
#' Compute mode (i.e., maximum) of Rdistance's version of the gamma 
#' distribution. 
#' 
#' @param params A matrix of Gamma distribution parameters. First column 
#' is the scale parameter, and is a fuction of covariates.
#' Second column is the shape parameter. 
#' 
#' @return A vector of the locations of the gamma modes associated 
#' with each row in the \code{params} matrix. 
#' 
#' @export
GammaModes <- function( params ){
  
  scl = exp(params[,1])
  shp = params[,2]
  
  b <- GammaReparam( shp = shp, scl = scl )
  
  shp <- b$shp
  scl <- b$scl
  
  mod <- (shp - 1) * scl
  
  mod

}

Try the Rdistance package in your browser

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

Rdistance documentation built on Jan. 10, 2026, 1:07 a.m.