adaptive_fnhat {kader} | R Documentation |
Specialized “Workhorse” Function for Kernel Adaptive Density Estimators
Description
Common specialized computational “workhorse” function to compute the kernel
adaptive density estimators both in eq. (1.6) of Srihera & Stute (2011) and
in eq. (4) of Eichner & Stute (2013) (together with several related
quantities) with a \sigma
that minimizes the estimated MSE using an
estimated \theta
. This function is “specialized” in that it expects
some pre-computed quantities (in addition to the point(s) at which the
density is to be estimated, the data, etc.). In particular, the estimator of
\theta
(which is typically the arithmetic mean of the data) is
expected to be already “contained” in those pre-computed quantities, which
increases the computational efficiency.
Usage
adaptive_fnhat(x, data, K, h, sigma, Ai, Bj, fnx, ticker = FALSE,
plot = FALSE, parlist = NULL, ...)
Arguments
x |
Numeric vector |
data |
Numeric vector |
K |
Kernel function with vectorized in- & output. |
h |
Numeric scalar, where (usually) |
sigma |
Numeric vector |
Ai |
Numeric matrix expecting in its i-th row |
Bj |
Numeric vector expecting |
fnx |
Numeric vector expecting |
ticker |
Logical; determines if a 'ticker' documents the iteration
progress through |
plot |
Logical or character or numeric and indicates if graphical
output should be produced. Defaults to |
parlist |
A list of graphical parameters; affects only the pdf-files
(if any are created at all). Default: |
... |
Possible further arguments passed to |
Details
The computational procedure in this function can be highly iterative because
for each point in x
(and hence for each row of matrix Ai
) the
MSE estimator is computed as a function of \sigma
on a (usually fine)
\sigma
-grid provided through sigma
. This happens by repeated
calls to bias_AND_scaledvar()
. The minimization in \sigma
is then performed by minimize_MSEHat()
using both a discrete
grid-search and the numerical optimization routine implemented in base R's
optimize()
. Finally, compute_fnhat()
yields the actual
value of the density estimator for the adapted \sigma
, i.e., for the
MSE-estimator-minimizing \sigma
.
(If necessary the computation over the \sigma
-grid is repeated after
extending the range of the grid until the estimator functions for both bias
and variance are not constant across the \sigma
-grid.)
Value
A list of as many lists as elements in x
, each with components
x
, y
, sigma.adap
, msehat.min
,
discr.min.smaller
, and sig.range.adj
whose meanings are as
follows:
x | the n coordinates of the points where the density is estimated. |
y | the estimate of the density value f(x) . |
sigma.adap | Minimizer of MSE-estimator (from function
minimize_MSEHat ). |
msehat.min | Minimum of MSE-estimator (from function
minimize_MSEHat ). |
discr.min.smaller | TRUE iff the numerically found minimum was
smaller than the discrete one (from function
minimize_MSEHat ). |
sig.range.adj | Number of adjustments of sigma-range. |
References
Srihera & Stute (2011) and Eichner & Stute (2013): see kader.
Examples
## Not run:
require(stats)
# Kernel adaptive density estimators for simulated N(0,1)-data
# computed on an x-grid using the rank transformation and the
# non-robust method:
set.seed(2017); n <- 100; Xdata <- sort(rnorm(n))
x <- seq(-4, 4, by = 0.5); Sigma <- seq(0.01, 10, length = 51)
h <- n^(-1/5)
x.X_h <- outer(x/h, Xdata/h, "-")
fnx <- rowMeans(dnorm(x.X_h)) / h # Parzen-Rosenblatt estim. at
# x_j, j = 1, ..., length(x).
# non-robust method:
theta.X <- mean(Xdata) - Xdata
adaptive_fnhat(x = x, data = Xdata, K = dnorm, h = h, sigma = Sigma,
Ai = x.X_h, Bj = theta.X, fnx = fnx, ticker = TRUE, plot = TRUE)
# rank transformation-based method (requires sorted data):
negJ <- -J_admissible(1:n / n) # rank trafo
adaptive_fnhat(x = x, data = Xdata, K = dnorm, h = h, sigma = Sigma,
Ai = x.X_h, Bj = negJ, fnx = fnx, ticker = TRUE, plot = TRUE)
## End(Not run)