Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


alR (version 2.2.0)

kdeGaussInt: Arc length of Gaussian KDE.

Description

Calculate the arc length for a univariate Gaussian kernel density estimator over a specified interval.

Usage

kdeGaussInt(mu, h, q1, q2, quantile)

kdeGaussInt2(mu, h, q1, q2, quantile)

kdeGaussIntApprox(mu, h, q1, q2, quantile)

kdeGaussIntApprox2(mu, h, q1, q2, quantile)

Arguments

mu

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

h

The kernel density estimator bandwidth.

q1

The point (or vector for kdeGaussInt2) specifying the lower limit of the arc length integral.

q2

The point (or vector for kdeGaussInt2) specifying the upper limit of the arc length integral.

quantile

Logical, TRUE/FALSE, whether q1 and q2 are quantiles, or actual points in the domain.

Value

kdeGaussInt: A list with the following components:

  • value: The resultant arc length.

  • abs.err: The absolute error between iterations. subdivisions: Number of subdivisions used in the numerical approximation.

  • neval: Number of function evaluations used by the numerical approximation.

kdeGaussInt2: A vector having length equal to that of the vector of lower quantile bounds, containing the arc lengths requested for a Gaussian kernel density estimator.

kdeGaussIntApprox: The resultant arc length.

kdeGaussIntApprox2: A vector having length equal to that of the vector of lower quantile bounds, containing the discrete arc lengths requested for a Gaussian kernel density estimator.

Details

For kdeGaussInt and kdeGaussInt2, the arc length of a univariate Gaussian kernel density estimator is approximated using the numerical integration C code implimented for R's integrate functions, i.e. using Rdqags. For this approximation, subdiv = 100 (100 subdivisions), and eps_abs = eps_rel = 1e-10, i.e. the absolute and relative errors respectively.

For kdeGaussIntApprox, the arc length is approximated by constructing the KDE, and then calculated as the sum of a finite collection of straight lines, based on the Pythagorean theorem.

Examples

Run this code
# NOT RUN {
library(alR)
mu <- rnorm(100)
h <- bw(mu, type=1)
kdeGaussInt(mu, h, 0.025, 0.975, TRUE)
kdeGaussInt(mu, h, -1.96, 1.96, FALSE)

kdeGaussInt2(mu, h, c(0.025, 0.5), c(0.5, 0.975), TRUE)
kdeGaussInt2(mu, h, c(-1.96, 0), c(0, 1.96), FALSE)

kdeGaussIntApprox(mu, h, 0.025, 0.975, TRUE)
kdeGaussIntApprox(mu, h, -1.96, 1.96, FALSE)

kdeGaussIntApprox2(mu, h, c(0.025, 0.5), c(0.5, 0.975), TRUE)
kdeGaussIntApprox2(mu, h, c(-1.96, 0), c(0, 1.96), FALSE)

# }

Run the code above in your browser using DataLab