Univariate Kernel Density Estimation

Provides an efficient implementation of univariate local polynomial kernel density estimators that can handle bounded and discrete data. See Geenens (2014) , Geenens and Wang (2018) , Nagler (2018a) , Nagler (2018b) .


Build status Linux Windows Build status CRAN version Coverage Status

Summary

  • implements a univariate kernel density estimator that can handle bounded and discrete data.
  • provides classical kernel density as well as log-linear and log-quadratic methods.
  • is highly efficient due to spline interpolation and a C++ backend.

For details, see the API documentation.

How to install

  • the stable release from CRAN:
install.packages("kde1d")
  • the latest development version:
# install.packages("devtools")
devtools::install_github("tnagler/[email protected]")

Examples

Unbounded data
x <- rnorm(100)                    # simulate data
fit <- kde1d(x)                    # estimate density
dkde1d(0, fit)                     # evaluate density estimate
summary(fit)                       # information about the estimate
plot(fit)                          # plot the density estimate
curve(dnorm(x), add = TRUE,        # add true density
      col = "red")
Bounded data, log-linear
x <- rgamma(100, shape = 1)        # simulate data
fit <- kde1d(x, xmin = 0, deg = 1) # estimate density
dkde1d(seq(0, 5, by = 1), fit)     # evaluate density estimate
summary(fit)                       # information about the estimate
plot(fit)                          # plot the density estimate
curve(dgamma(x, shape = 1),        # add true density
      add = TRUE, col = "red",
      from = 1e-3)
Discrete data
x <- rbinom(100, size = 5, prob = 0.5)  # simulate data
x <- ordered(x, levels = 0:5)           # declare as ordered
fit <- kde1d(x)                         # estimate density
dkde1d(sort(unique(x)), fit)            # evaluate density estimate
summary(fit)                            # information about the estimate
plot(fit)                               # plot the density estimate
points(ordered(0:5, 0:5),               # add true density
       dbinom(0:5, 5, 0.5), col = "red")
Weighted estimate
x <- rnorm(100)                         # simulate data
weights <- rexp(100)                    # weights as in Bayesian bootstrap
fit <- kde1d(x, weights = weights)      # weighted fit
plot(fit)                               # compare with unweighted fit
lines(kde1d(x), col = 2)

References

Geenens, G. (2014). Probit transformation for kernel density estimation on the unit interval. Journal of the American Statistical Association, 109:505, 346-358, arXiv:1303.4121

Geenens, G., Wang, C. (2018). Local-likelihood transformation kernel density estimation for positive random variables. Journal of Computational and Graphical Statistics, to appear, arXiv:1602.04862

Loader, C. (2006). Local regression and likelihood. Springer Science & Business Media.

Nagler, T. (2018a). A generic approach to nonparametric function estimation with mixed data. Statistics & Probability Letters, 137:326–330, arXiv:1704.07457

Nagler, T. (2018b). Asymptotic analysis of the jittering kernel density estimator. Mathematical Methods of Statistics, in press, arXiv:1705.05431

News

kde1d 0.4.0

NEW FEATURE

  • allow weights for observations via kde1d(..., weights = ) (#29).

BUG FIX

  • stabilized bandwidth selection in presence of ties and outliers.

  • keep debug symbols on Linux systems (following a request by Prof. Ripley).

kde1d 0.2.0

NEW FEATURES

  • improved stability of density estimates near a boundary (#21).

BUG FIXES

  • consistent behavior when dkde1d() and pkde1d() are called with non-ordered input although data are discrete (#19).

  • fixed bug in computation of kernel density estimates (#20).

  • adapt minimum bw allowed for discrete data to truncated Gaussian kernel (#20).

kde1d 0.1.2

NEW FEATURES

  • Faster interpolation using binary search to find cells (#17).

BUG FIXES

  • Fixed heap buffer overflows in interpolation routines (#15, #16).

  • Fixed bounds of cdf for fit discrete data when long doubles are not supported (#16).

kde1d 0.1.0

  • Initial release.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("kde1d")

0.4.0 by Thomas Nagler, 5 months ago


https://github.com/tnagler/kde1d


Report a bug at https://github.com/tnagler/kde1d/issues


Browse source code at https://github.com/cran/kde1d


Authors: Thomas Nagler [aut, cre] , Thibault Vatter [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cctools, graphics, Rcpp, qrng, stats, utils

Suggests testthat

Linking to BH, Rcpp, RcppEigen

System requirements: C++11


Imported by rvinecopulib, vinereg.


See at CRAN