compute_fnhat {kader} | R Documentation |
“Unified” Function for Kernel Adaptive Density Estimators
Description
“Unified” function to compute the kernel density estimator both of Srihera & Stute (2011) and of Eichner & Stute (2013).
Usage
compute_fnhat(x, data, K, h, Bj, sigma)
Arguments
x |
Numeric vector with the location(s) at which the density estimate is to be computed. |
data |
Numeric vector |
K |
A kernel function (with vectorized in- & output) to be used for the estimator. |
h |
Numeric scalar for bandwidth |
Bj |
Numeric vector expecting |
sigma |
Numeric scalar for value of scale parameter |
Details
Implementation of both eq. (1.6) in Srihera & Stute (2011) for given and
fixed scalars \sigma
and \theta
, and eq. (4) in Eichner & Stute
(2013) for a given and fixed scalar \sigma
and for a given and fixed
rank transformation (and, of course, for fixed and given location(s) in
x
, data (X_1, \ldots, X_n)
, a kernel function K
and a
bandwidth h
). The formulas that the computational version implemented
here is based upon are given in eq. (15.3) and eq. (15.9), respectively, of
Eichner (2017). This function rests on preparatory computations done in
fnhat_SS2011
or fnhat_ES2013
.
Value
A numeric vector of the same length as x
with the estimated
density values from eq. (1.6) of Srihera & Stute (2011) or eq. (4)
of Eichner & Stute (2013).
Note
In case of the rank transformation method the data are expected to be sorted in increasing order.
References
Srihera & Stute (2011), Eichner and Stute (2013), and Eichner
(2017): see kader
.
Examples
require(stats)
# The kernel density estimators for simulated N(0,1)-data and a single
# sigma-value evaluated on a grid using the rank transformation and
# the non-robust method:
set.seed(2017); n <- 100; Xdata <- rnorm(n)
xgrid <- seq(-4, 4, by = 0.1)
negJ <- -J_admissible(1:n / n) # The rank trafo requires
compute_fnhat(x = xgrid, data = sort(Xdata), # sorted data!
K = dnorm, h = n^(-1/5), Bj = negJ, sigma = 1)
theta.X <- mean(Xdata) - Xdata # non-robust method
compute_fnhat(x = xgrid, data = Xdata, K = dnorm, h = n^(-1/5),
Bj = theta.X, sigma = 1)