% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{vector_mode}
\alias{vector_mode}
\title{Compute mode of a vector, with optional filtering for N datapoints}
\usage{
vector_mode(
  x,
  min_value_count = 3L,
  n_bins = 512L,
  adjust = 1,
  kernel_width_in_sd = 3,
  bandwidth_method = "nrd",
  mode_frac_maxdens = 1,
  na_mode = "check"
)
}
\arguments{
\item{x}{numeric input vector, may contain non-finite values (removed if \code{na_mode} is left to default)}

\item{min_value_count}{the minimum number of values overlapping between a pair of columns (if there are fewer overlapping values, respective rescaling is not computed)}

\item{n_bins}{grid size for density computation (the resolution / number of data points to use for binning column diffs)}

\item{adjust}{bandwidth adjust factor for density computation}

\item{kernel_width_in_sd}{maximum distance in standard deviations at which we'll include data points for the Gaussian kernal. Typically 3 or 4}

\item{bandwidth_method}{method in which this function computes bandwidth and optionally trims the data prior to binning. "nrd" is the robust, safe default. "nrd_fast" is faster and yields similar results for most distributions. Use "nrd_fastest" only when all pairwise distances are known to be near gaussian (i.e. no strong outliers and sd() is a reliable metric). "nrd_subset" is an experimental option that may be removed, it is fast but heavily favors symmetric distributions and is thus biased !

Valid options:
\itemize{
\item \code{"nrd_fastest"} ; use all data points, for bandwidth don't use IQR. Sensitive to outliers !
\item \code{"nrd_fast"} ; trim to quantiles 0.05 and 0.95, then use sd over these data points to compute bandwidth. Not as robust as the original nrd method, which also considers IQR, but much faster.
\item \code{"nrd"} ; adapted version of nrd; instead of IQR and sd we use IQR and sd over data trimmed at quantiles 0.05 and 0.95. Since we already sorted the data, computing sd on trimmed subset is 'free'
}}

\item{mode_frac_maxdens}{set to 1 to return the x-coordinate where the density is highest (mode). Setting this to a value < 1 will make this function compute not the mode, but the mean (x) value of the density where the density is some fraction higher than the maximum density. Typical value; 1. Optionally, set to 0.9 or 0.8 for possibly more robust center-finding, depending in your data distribution. Must not be smaller than 0.1 but recommended to never be lower than 0.7}

\item{na_mode}{string value that indicated how should we should deal with NA values (default). "check" = test if NA values are present and if so, remove these. "present" = you already know NA values are present so we can skip the check for NA values for efficiency. "unchecked" = you guarantee that there are no NA values in input, thus we'll use the fastest code paths that skip over any NA checks downstream; ONLY select this if you are sure there are no NA/NaN/Inf/-Inf values !}
}
\value{
a single numeric value representing the mode
}
\description{
Compute measure of central tendency using efficient C++ code
}
