demoKde (version 0.9-4)

demoKde-package: Kernel density estimation demonstration and exploration

Description

Teaching demonstration code for kernel density estimates. KDEs are computed in native R code directly from the definition. Kernels may be supplied as a function in a standard form, thus allowing alternative kernel functions to be devised and empirically investigated. A wide selection of kernel function is also provided with the package.

Arguments

Details

Package: demoKde
Type: Package
Version: 0.9-4
Date: 2017-02-02
License: GPL-2

References

See http://en.wikipedia.org/wiki/Kernel_(statistics) for details of the kernel functions.

See Also

density

Examples

Run this code
# NOT RUN {
if(require("graphics")) {
  with(MASS::Boston, {
      Criminality <- log(crim)
      hist(Criminality, freq=FALSE, main="", border="grey", las=1)
      lines(stats::density(Criminality), col="skyblue", lwd=8)
      lines(kde(Criminality))
      lines(kde(Criminality, kernel = kernelUniform), col="red")
      rug(jitter(Criminality), col="blue")
      legend("topright", c("density histogram",
        "KDE gaussian (denstiy)", "KDE gaussian (kde)",
        "KDE rectangular (kde)"), lty = "solid", lwd=c(1,8,1,1),
        col=c("grey", "skyblue", "black", "red"), bty="n")
  })
}
# }

Run the code above in your browser using DataLab