Learn R Programming

alR (version 2.2.0)

dkdeGauss: Gaussian kernel density estimator.

Description

Estimate a density function using a kernel density estimator with a Gaussian kernel.

Usage

dkdeGauss(x, mu, h)

pkdeGauss(x, mu, h)

qkdeGauss(x, mu, h)

Arguments

x

A data point, or quantile, at which the kernel density estimator should be evaluated.

mu

A vector of data points on which the kernel density estimator is based.

h

The kernel density estimator bandwidth.

Value

dkdeGauss: The estimated value of the density function at the point x.

pkdeGauss: The estimated value of the cumulative distribution function at the point x.

qkdeGauss: A list with the following components:

  • result: The xth quantile of the Gaussian kernel density estimator.

  • value: The value of the cumulative distribution function of the Gaussian kernel density estimator at the xth quantile.

  • obj.fun: The value of the objective function resulting from Brent's method; should be less than 1e-10.

  • iterations: Number of iterations for Brent's method in order to achieve the desired accuracy.

  • steps: Number of range expansions of the search boundaries for Brent's method.

Details

The cumulative distribution function is calculated using the numerical integration C code implimented for R's integrate functions, i.e. using Rdqagi. For this approximation, subdiv = 100 (100 subdivisions), and eps_abs = eps_rel = 1e-10, i.e. the absolute and relative errors respectively.

The quantiles of the Gaussian kernel density estimator are calculated using Brent's method. This method requires an interval in which a solution is saught. The objective funcion for which a zero is saught is dkdeGauss-x, where x is the quantile saught. The first interval in which a solution is searched for, corresponds to the range of mu, and is expanded in multiples thereof in consequtive steps. The maximum number of iterations is set at 1000, and the accuracy saught between iterations, is set at 1e-10.

Examples

Run this code
# NOT RUN {
library(alR)
x <- rnorm(100)
h_x <- bw(x, type=1)
dkdeGauss(0, x, h_x)
pkdeGauss(0, x, h_x)
qkdeGauss(0.5, x, h_x)
# }

Run the code above in your browser using DataLab