Description Usage Arguments Details Value References See Also Examples
Implementation of eq. (4) in Eichner & Stute (2013) for a given and fixed scalar σ, for rank transformation function J (and, of course, for fixed and given location(s) in x, data (X_1, …, X_n), a kernel function K, and a bandwidth h).
1  | fnhat_ES2013(x, data, K, h, ranktrafo, sigma)
 | 
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. Missing values are not allowed and entail an error.  | 
K | 
 A kernel function to be used for the estimator.  | 
h | 
 Numeric scalar for bandwidth h.  | 
ranktrafo | 
 A function used for the rank transformation.  | 
sigma | 
 Numeric scalar for value of scale parameter σ.  | 
The formula upon which the computational version implemented here is based
is given in eq. (15.9) of Eichner (2017). This function does mainly only a
simple preparatory computation and then calls compute_fnhat
which does the actual work.
An object with class "density" whose underlying structure is
a list containing the following components (as described in
density), so that the print and
plot methods for density-objects are
immediately available):
x  | the n coordinates of the points where the density is estimated. | 
y  | the estimated density values from eq. (4) in Eichner & Stute (2013). | 
bw  | the bandwidth used. | 
n  | the sample size. (Recall: missing or infinite values are not allowed here.) | 
call  | the call which produced the result. | 
data.name  | the deparsed name of the x argument. | 
has.na  | logical, for compatibility (always FALSE). | 
| Additionally: | |
ranktrafo  | as in Arguments. | 
sigma  | as in Arguments. | 
Eichner & Stute (2013) and Eichner (2017): see kader.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41  | require(stats);   require(grDevices);   require(datasets)
 # Simulated N(0,1)-data and one sigma-value
set.seed(2016);     n <- 100;     d <- rnorm(n)
xgrid <- seq(-4, 4, by = 0.1)
(fit <- fnhat_ES2013(x = xgrid, data = d, K = dnorm, h = n^(-1/5),
  ranktrafo = J2, sigma = 1) )
plot(fit, ylim = range(0, dnorm(0), fit$y), col = "blue")
curve(dnorm, add = TRUE);   rug(d, col = "red")
legend("topleft", lty = 1, col = c("blue", "black", "red"),
  legend = expression(hat(f)[n], phi, "data"))
 # The same data, but several sigma-values
sigmas <- seq(1, 4, length = 4)
(fit <- lapply(sigmas, function(sig)
  fnhat_ES2013(x = xgrid, data = d, K = dnorm, h = n^(-1/5),
    ranktrafo = J2, sigma = sig)) )
ymat <- sapply(fit, "[[", "y")
matplot(x = xgrid, y = ymat, type = "l", lty = 1, col = 2 + seq(sigmas),
  ylim = range(0, dnorm(0), ymat), main = "", xlab = "", ylab = "Density")
curve(dnorm, add = TRUE);   rug(d, col = "red")
legend("topleft", lty = 1, col = c("black", "red", NA), bty = "n",
  legend = expression(phi, "data", hat(f)[n]~"in other colors"))
 # Old-Faithful-eruptions-data and several sigma-values
d <- faithful$eruptions;     n <- length(d);     er <- extendrange(d)
xgrid <- seq(er[1], er[2], by = 0.1);    sigmas <- seq(1, 4, length = 4)
(fit <- lapply(sigmas, function(sig)
   fnhat_ES2013(x = xgrid, data = d, K = dnorm, h = n^(-1/5),
     ranktrafo = J2, sigma = sig)) )
ymat <- sapply(fit, "[[", "y");     dfit <- density(d, bw = "sj")
plot(dfit, ylim = range(0, dfit$y, ymat), main = "", xlab = "")
rug(d, col = "red")
matlines(x = xgrid, y = ymat, lty = 1, col = 2 + seq(sigmas))
legend("top", lty = 1, col = c("black", "red", NA), bty = "n",
  legend = expression("R's est.", "data", hat(f)[n]~"in other colors"))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.