R/estimate_mode.R

Defines functions estimate_mode

Documented in estimate_mode

#' Function to estimate mode of MCMC samples
#' 
#' Based on codes from 'http://stackoverflow.com/questions/2547402/is-there-a-built-in-function-for-finding-the-mode'
#' see the comment by Rasmus Baath
#' 
#' @param x MCMC samples or some numeric or array values. 
#' @importFrom stats density
#' @export 
#' 
estimate_mode <- function(x) {
  d = density(x)
  Estimate = d$x[which.max(d$y)]
  return(Estimate)
}

Try the hBayesDM package in your browser

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

hBayesDM documentation built on Sept. 23, 2022, 9:06 a.m.