Title
mm_kern() -- Kernel functions
Syntax
real matrix mm_kern(k, real matrix z)
real matrix mm_kint(k, real scalar l [, real matrix z])
real scalar mm_kdel0(k)
where k: string scalar containing "epanechnikov", "epan2" (default), "biweight", "triweight", "cosine", "gaussian", "parzen", "rectangle" or "triangle"
real matrix mm_kern_name(real matrix z)
real matrix mm_kint_name(real scalar l [, real matrix z])
real scalar mm_kdel0_name()
where name is epanechnikov, epan2, biweight, triweight, cosine, gaussian, parzen, rectangle, or triangle
Description
mm_kern(k, z) returns the value of kernel function k for the input value z. k is the kernel's name and may be abbreviated as indicated above.
mm_kint(k, l, z) returns kernel integrals from minus infinity to z or, if z is omitted, from minus infinity to plus infinity. l determines the type of integral. Let K(x) denote the kernel function. Then the integrals returned for different choices of l are:
l integrated function ------------------------- 1 K(x) 2 K(x)^2 3 x * K(x) 4 x^2 * K(x)
Note that mm_kint(k, 2) returns the so-called "roughness" of kernel function. mm_kint(k, 4) returns the variance of the kernel function.
mm_kdel0(k) returns the canonical bandwidth of kernel function k.
Instead of using the wrappers mm_kern(), mm_kint(), and mm_kdel0() you may prefer to apply mm_kern_name(), mm_kint_name(), and mm_kdel0_name() directly, where name stands for epanechnikov, epan2, biweight, triweight, cosine, gaussian, parzen, rectangle, or triangle.
Remarks
The formulas for the kernels and their properties can be found in http://fmwww.bc.edu/RePEc/bocode/k/kdens.pdf.
Conformability
mm_kern(k, z): k: 1 x 1 z: r x c result: r x c.
mm_kint(k, l, z): k: 1 x 1 l: 1 x 1 z: r x c result: r x c (or 1 x 1 if z is omitted).
mm_kdel0(k): k: 1 x 1 result: 1 x 1.
mm_kern_name(z): z: r x c result: r x c.
mm_kint_name(l, z): l: 1 x 1 z: r x c result: r x c (or 1 x 1 if z is omitted).
mm_kdel0_name(): result: 1 x 1.
Diagnostics
If argument k in mm_kern(), mm_kint(), and mm_kdel0() is empty (i.e. k==""), the epan2 kernel is used.
Source code
mm_kern.mata
Author
Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch
Aknowledgements
Shouts to Matthias Naef for helping me with the math.
Also see
Online: help for kdens (if installed), moremata