KDE | R Documentation |
KDE
returns the probability function for the kernel density estimator
KDE( data, weights = NULL, bandwidth = NULL, df = Inf, density.name = "kde", value.name = "Value", discrete = FALSE, discrete.warn = TRUE, to.environment = FALSE, envir = .GlobalEnv )
data |
Input data for the kernel density estimator (a numeric vector) |
weights |
Weights for the kernel density estimator (a numeric vector with the same length as the data) |
bandwidth |
Bandwidth for the KDE; if |
df |
Degrees-of-freedom for the T-distribution |
density.name |
Name of the KDE distribution; used for naming of the probability functions (a character string) |
value.name |
Name of the values in the data; used for naming the plot of the KDE |
discrete |
Logical; if |
discrete.warn |
Logical; if |
to.environment |
Logical; if |
envir |
The environment where the probability functions are loaded (if |
The kernel density estimator for a set of input data is obtained by taking a mixture distribution
consisting of a (possibly weighted) combination of kernels. In this function we compute the KDE
using the kernel of the T-distribution; the function can also estimate a discretised version of the
KDE (taken over the integers) if required. The degrees-of-freedom and the bandwidth for the KDE can
be specified in the inputs; if the bandwidth is not specified then it are estimated using the methods
set out in Sheather and Jones (1991) used in the stats::density
function. The output of the
function is a list of class kde
that contains the probability functions for the KDE and
associated information. The output object can be plotted to show the density function for the KDE.
Note: The function has an option to.environment
to allow the user to load the probability
functions to the global environment or another specified environment. If this is set to TRUE
then the probability functions are loaded to the specified environment in addition to appearing as
elements of the output; there is a message informing the user if existing objects in the global
environment were overwritten. If the functions are not loaded to the environment then the user
can use the function KDE.load
to load them later from the produced object.
A kde
object containing the probability functions for the kernel density estimator
k <- KDE(rnorm(500)) print(k) plot(k) KDE.load(k, environment()); ls()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.