compute_fnhat: "Unified" Function for Kernel Adaptive Density Estimators

Description Usage Arguments Details Value Note References Examples

Description

“Unified” function to compute the kernel density estimator both of Srihera & Stute (2011) and of Eichner & Stute (2013).

Usage

1
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 (X_1, …, X_n) of the data from which the estimate is to be computed.

K

A kernel function (with vectorized in- & output) to be used for the estimator.

h

Numeric scalar for bandwidth h.

Bj

Numeric vector expecting (-J(1/n), …, -J(n/n)) as produced in fnhat_SS2011 in case of the rank transformation method (using an admissible rank transformation as implemented by J_admissible), but (\hat θ - X_1, ..., \hat θ - X_n) as produced in fnhat_ES2013 in case of the non-robust method.

sigma

Numeric scalar for value of scale parameter σ.

Details

Implementation of both eq. (1.6) in Srihera & Stute (2011) for given and fixed scalars σ and θ, and eq. (4) in Eichner & Stute (2013) for a given and fixed scalar σ and for a given and fixed rank transformation (and, of course, for fixed and given location(s) in x, data (X_1, …, 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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)

GerritEichner/kader documentation built on May 10, 2019, 1:14 p.m.