Description Usage Arguments Details Value References Examples

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 *σ* that minimizes the estimated MSE using an
estimated *θ*. 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
*θ* (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.

1 2 |

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

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 *σ* on a (usually fine)
*σ*-grid provided through `sigma`

. This happens by repeated
calls to `bias_AND_scaledvar()`

. The minimization in *σ*
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 *σ*, i.e., for the
MSE-estimator-minimizing *σ*.
(If necessary the computation over the *σ*-grid is repeated after
extending the range of the grid until the estimator functions for both bias
and variance are *not constant* across the *σ*-grid.)

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

Srihera & Stute (2011) and Eichner & Stute (2013): 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 | ```
## 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)
``` |

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.