# kerndensmeasure: Statistic measuring closeness to symmetric unimodal... In otrimle: Robust Model-Based Clustering

## Description

Density-based distance between one-dimensional data and a unimodal symmetric distribution about the data mean based on Pons (2013, p.79), adapted by Hennig and Coretto (2021), see details.

## Usage

 ```1 2``` ``` kerndensmeasure(x,weights=rep(1,nrow(as.matrix(x))),maxq=qnorm(0.9995), kernn=100) ```

## Arguments

 `x` vector. One-dimensional dataset. `weights` non-negative vector. Relative weights of observations (will be standardised to sup up to one internally). `maxq` densities are evaluated between `mean(x)-maxq` and `mean(x)+maxq`. `kernn` integer. Number of points at which the density is evaluated, input parameter `n` of `density`. This should be even.

## Details

Function `density` is used in order to compute a kernel density estimator from the data. The `kernn` values of the density are then ordered from the pargest to the smallest. Beginning from the largest to the smallest, pairs of two values are formed (largest and largest biggest, third and fourth largest, and so on). Each pair is replaced by two copies of the average of the two values. Then on each side of the mean one of each copy is placed from the biggest to the smallest, and this produces a symmetric density about the mean. The the root mean squared difference between this and the original density is computed.

## Value

A list with components `cp, cpx, measure`.

 `cp` vector of generated symmetric density values from largest to smallest (just one copy, sp `kernn/2` values). `cpx` `y`-component of `density`-output. `measure` root mean squared difference between the densities.

## References

Hennig, C. and P.Coretto (2021). An adequacy approach for deciding the number of clusters for OTRIMLE robust Gaussian mixture based clustering. To appear in Australian and New Zealand Journal of Statistics, https://arxiv.org/abs/2009.00921.

Pons, O. (2013). Statistical Tests of Nonparametric Hypotheses: Asymptotic Theory. World Scientific, Singapore.

`kerndensp`
 ```1 2 3``` ``` set.seed(124578) x <- runif(20) str(kerndensmeasure(x)) ```