This function estimates the mode (the most frequent value) of a given
numeric vector using kernel density estimation. The mode is identified
as the value where the kernel density is maximized.
Arguments
- z
A numeric vector containing the values from which the mode is to be estimated.
- n
An integer specifying the number of equally spaced grid points for kernel density estimation (default is 512).
Value
A numeric value representing the estimated mode of the distribution.
Examples
# Generate random data from a normal distribution
set.seed(123)
data <- rnorm(1000)
# Compute the mode of the distribution
mode_stat(data)
#> [1] 0.006799071