wdens: Weight a biased sample to estimate probability density

View source: R/weighted_density_fcn.R

wdensR Documentation

Weight a biased sample to estimate probability density

Description

Calculate a kernel density estimate while correcting for selection bias by weighting the kernels.

Usage

wdens(x, w, bw = "brt", reflect = FALSE, a = NULL, b = NULL, ...)

Arguments

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

bw

A method to estimate the kernel bandwidth from Borrajo et al. 2017. rt is the rule-of-thumb estimate; brt is a bootstrap estimate with the rule-of-thumb as the pilot. Alternatively, a numeric value to pass to density.

reflect

Logical: should boundary reflection be applied?

a

The lower limit for density estimation, on the original, untransformed scale. Default is min(x).

b

The upper limit for density estimation, on the original, untransformed scale. Default is max(x).

...

Further arguments passed on to density.

Details

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.

Value

An S3 density.

References

\insertRef

Borrajo17kerneval

\insertRef

Jones91kerneval

See Also

transdens


GwenAntell/kerneval documentation built on July 21, 2023, 6:23 p.m.