File: naive.R

package info (click to toggle)
r-cran-modeest 2.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 280 kB
  • sloc: makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#' @title 
#' The Chernoff or 'naive' mode estimator
#' 
#' @description 
#' This estimator, also called the *naive* mode estimator, is defined as the 
#' center of the interval of given length containing the most observations. 
#' It is identical to Parzen's kernel mode estimator, when the kernel is chosen 
#' to be the uniform kernel.
#' 
#' @note 
#' The user may call \code{naive} through 
#' \code{mlv(x, method = "naive", bw)}. 
#' 
#' @references 
#' \itemize{ 
#'   \item Chernoff H. (1964). 
#'   Estimation of the mode. 
#'   \emph{Ann. Inst. Statist. Math.}, \bold{16}:31-41.
#'   
#'   \item Leclerc J. (1997). 
#'   Comportement limite fort de deux estimateurs du mode : 
#'   le shorth et l'estimateur naif. 
#'   \emph{C. R. Acad. Sci. Paris, Serie I}, \bold{325}(11):1207-1210.
#' }
#' 
#' @param x
#' numeric. Vector of observations.
#' 
#' @param bw 
#' numeric. The smoothing bandwidth to be used. Should belong to (0, 1). See below.
#' 
#' @return 
#' A numeric vector is returned, the mode estimate, 
#' which is the center of the interval of length \code{2*bw} 
#' containing the most observations.
#' 
#' @seealso 
#' \code{\link[modeest]{mlv}} for general mode estimation; 
#' \code{\link[modeest]{parzen}} for Parzen's kernel mode estimation. 
#' 
#' @export
#' @aliases Chernoff chernoff
# #' @rdname parzen 
#' 
#' @examples 
#' # Unimodal distribution
#' x <- rf(10000, df1 = 40, df2 = 30)
#' 
#' ## True mode
#' fMode(df1 = 40, df2 = 30)
#' 
#' ## Estimate of the mode
#' mean(naive(x, bw = 1/4))
#' mlv(x, method = "naive", bw = 1/4)
#' 
naive <-
function(x,
         bw = 1/2)
{
  parzen(x = x, bw = bw, kernel = "uniform", abc = TRUE)
}