| Type: | Package | 
| Title: | Mode Estimation, Even in the Multimodal Case | 
| Version: | 0.0.1 | 
| Description: | Function ModEstM() is the only one of this package, it estimates the modes of an empirical univariate distribution. It relies on the stats::density() function, even for input control. Due to very good performance of the density estimation, computation time is not an issue. The multiple modes are handled using dplyr::group_by(). For conditions and rates of convergences, see Eddy (1980) <doi:10.1214/aos/1176345080>. | 
| Depends: | R (≥ 4.1) | 
| License: | GPL-3 | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.1.2 | 
| Imports: | dplyr, rlang, stats | 
| NeedsCompilation: | no | 
| Packaged: | 2022-05-19 07:10:02 UTC; Jerome | 
| Author: | Jerome Collet [aut, cre] | 
| Maintainer: | Jerome Collet <jeromepcollet@gmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2022-05-19 08:10:02 UTC | 
Computes the modes, i.e. the local maxima fo the density function for a given empirical distribution
Description
Computes the modes, i.e. the local maxima fo the density function for a given empirical distribution
Usage
ModEstM(x, ...)
Arguments
| x | : the random values | 
| ... | : other parameters, passed to density. The main use of this feature is to increase "adjust" in order to suppress spurious local density maxima. | 
Value
a list of the modes, in decreasing order of the corresponding density. It allows to suppress the less significant modes, if necessary.
Examples
require(dplyr)
x1 <- c(rbeta(1000, 23, 4))
x2 <- c(rbeta(1000, 23, 4), rbeta(1000, 4, 16))
Distribs <-
  rbind(data.frame(case = 1, XX = x1), data.frame(case = 2, XX = x2))
Adjust <- 1
Modes <- Distribs |> 
  group_by(case) |> 
  summarise(mode = ModEstM(XX, adjust = Adjust))
Modes$case
Modes$mode
ChosenCase <- 2
values <- Distribs |>
  filter(case == ChosenCase) |> 
  pull(XX)
plot(density(values, adjust = Adjust))
abline(v = Modes |> filter(case == ChosenCase) |> pull(mode) |> unlist())