View source: R/weighted_density_fcn.R
wdens | R Documentation |
Calculate a kernel density estimate while correcting for selection bias by weighting the kernels.
wdens(x, w, bw = "brt", reflect = FALSE, a = NULL, b = NULL, ...)
x |
A numeric vector from which the estimate is to be computed. |
w |
A function that gives the probability of observation
at any single value in the range of |
bw |
A method to estimate the kernel bandwidth from Borrajo et al. 2017.
|
reflect |
Logical: should boundary reflection be applied? |
a |
The lower limit for density estimation,
on the original, untransformed scale. Default is |
b |
The upper limit for density estimation,
on the original, untransformed scale. Default is |
... |
Further arguments passed on to |
The kernel on each datum is weighted by the inverse of the observation
probability at that point, 1/w(X)
. Weighted kernel estimation should
not be confused with adaptive kenel estimation. Both approaches
modify the individual kernels that contribute to an estimate.
However, in adaptive KDE the badwidth of each kernel is adjusted,
whereas in weighted KDE the bandwidth is constant while the height
(total probability density) of each kernel is adjusted.
Weighted KDE is the method data that has received the most attention
in the statistics literature for selection-biased data, beginning with
the foundational paper of Jones (1991). The method is a slight modification
of classical KDE and does not add onerous calculation, making it attractive.
However, the choice of bandwidth is complicated. wdens
calls the
internal selectbw
function to select a bandwidth following the
user-specified bootstrap methods of Borrajo and others (2017).
The bandwidth will be calculated for a Gaussian kernel, so wdens
will not accept the additional arguments kernel
, window
, or
width
. Other arguments will be passed to density
.
An S3 density.
Borrajo17kerneval
\insertRefJones91kerneval
transdens
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.