Computes the complete or incomplete \(m\)th moment of a smoothing kernel.
kernel.moment(m, r, kernel = "gaussian", mean=0, sd=1/kernel.factor(kernel))
A single number, or a numeric vector of the same length as r
.
Exponent (order of moment). An integer.
Upper limit of integration for the incomplete moment.
A numeric value or numeric vector.
Set r=Inf
to obtain the complete moment.
String name of the kernel.
Options are
"gaussian"
, "rectangular"
,
"triangular"
,
"epanechnikov"
,
"biweight"
,
"cosine"
and "optcosine"
.
(Partial matching is used).
Optional numerical values giving the mean and standard deviation of the kernel.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Martin Hazelton Martin.Hazelton@otago.ac.nz.
Kernel estimation of a probability density in one dimension
is performed by density.default
using a kernel function selected from the list above.
For more information about these kernels,
see density.default
.
The function kernel.moment
computes the integral
$$
\int_{-\infty}^r t^m k(t) dt
$$
where \(k(t)\) is the selected kernel, \(r\) is the upper limit of
integration, and \(m\) is the exponent or order.
Note that, if mean
and sd
are not specified, the
calculations assume that \(k(t)\) is the standard form of the kernel,
which has support \([-1,1]\) and
standard deviation \(sigma = 1/c\) where c = kernel.factor(kernel)
.
The code uses the explicit analytic expressions when
m = 0, 1, 2
and numerical integration otherwise.
density.default
,
dkernel
,
kernel.factor
,
kernel.squint
kernel.moment(1, 0.1, "epa")
curve(kernel.moment(2, x, "epa"), from=-1, to=1)
Run the code above in your browser using DataLab