Description Usage Arguments Details Value Note References Examples

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

1 | ```
compute_fnhat(x, data, K, h, Bj, sigma)
``` |

`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 |

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`

.

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).

In case of the rank transformation method the data are expected to be sorted in increasing order.

Srihera & Stute (2011), Eichner and Stute (2013), and Eichner
(2017): see `kader`

.

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.