Kernel smoothing¶
Kernel smoothing is a non parametric estimation method of the probability density function of a distribution.
Introduction¶
Let be a random variable with probability density function
.
Given a sample of independent observations
of
and any point
, the kernel smoothing estimator provides
an approximation
of
.
In dimension 1, the kernel smoothed probability density function has the following expression,
where K is the univariate kernel, n the sample size and
the univariate random sample with
([wand1994] eq. 2.2 page 12):
(1)¶
The kernel K is a function satisfying:
The parameter h is called the bandwidth.
Multivariate kernels¶
In dimension , the kernel may be defined as a product kernel
,
as follows where
([wand1994] eq. 2.2 page 91):
The kernel smoothed probability density function in dimension d is:
where is the d-variate random sample
which components are denoted
.
In the multivariate case, the bandwidth is the vector
.
Asymptotic error and asymptotically optimal bandwidth¶
The quality of the approximation may be controlled by the AMISE (Asymptotic Mean Integrated Square error) criteria defined as follows.
By definition, the mean squared error (MSE) at point is
(see [scott2015] eq. page 40, [wand1994] pages 14-21):
It can be proved that the mean squared error is the sum of the variance and the squared bias:
where the bias is:
The MSE depends on the point where the density is evaluated. The mean integrated squared error (MISE) is (see [scott2015] eq. page 41):
Finally, the asymptotic mean integrated squared error (AMISE),
denoted is defined as the two first terms
in the Taylor series expansion of
when
tends to infinity.
The quality of the estimation essentially depends on the value of the bandwidth h. In dimension 1, the bandwidth that minimizes the AMISE criteria is (see [wand1994] eq 2.13 page 22):
(2)¶
where the rugosity of the kernel is:
and the second raw moment of the kernel is:
In the equation (2), the expression is the rugosity of
the second derivative of the density probability function
that
we wish to approximate.
Since, by hypothesis, the true density
is unknown, its
second derivative is also unknown.
Hence the equation (2) cannot be used directly to compute the bandwidth.
We have ([wand1994] page 67):
where:
Therefore:
(3)¶
Several methods exist to evaluate the optimal bandwidth based on different approximations of
:
Silverman’s rule in dimension 1,
the plug-in bandwidth selection,
Scott’s rule in dimension d.
Efficiency of a kernel¶
Let be a kernel.
We may be interested if a particular kernel may be able to reduce the
estimation error.
The efficiency of a kernel is (see [scott2015] page 151):
where is Epanechnikov’s kernel.
The AMISE error is proportional to the efficiency (see [scott2015]
eq. 6.25 page 151):
The next table presents several kernels available in the library and their associated variance, rugosity and efficiency. We see that the best kernel is Epanechnikov’s kernel. We also see that there is not much difference between the different kernels. This is one of the reasons why the normal kernel is often used.
Kernel |
||||
---|---|---|---|---|
Epanechnikov |
0.2000 |
0.6000 |
0.2683 |
100.00 % |
Biweight |
0.1429 |
0.7143 |
0.2700 |
99.39 % |
Quartic |
0.1429 |
0.7143 |
0.2700 |
99.39 % |
Triweight |
0.1111 |
0.8159 |
0.2720 |
98.67 % |
Triangular |
0.1667 |
0.6667 |
0.2722 |
98.59 % |
Normal |
1.0000 |
0.2821 |
0.2821 |
95.12 % |
Uniform |
0.3333 |
0.5000 |
0.2887 |
92.95 % |
Logistic |
3.2899 |
0.1667 |
0.3023 |
88.76 % |
Table 1. Efficiency of several order 2 kernels.
Silverman’s rule (dimension 1)¶
In this section, we consider a random variable i.e. .
If the density p is normal with standard deviation
,
then the term
can be exactly evaluated.
By definition, the Silverman rule for the bandwidth is
the optimal bandwidth of the AMISE criteria when the true density p is normal
(see [silverman1986] page 45):
(4)¶
The Silverman rule is based on the hypothesis that the true density p is close to the normal density, even if the density p is not necessarily normal.
The equation (4) is accurate when the density is not far from a normal one. In the special case where we use the normal kernel, the Silverman rule is (see [silverman1986] eq 3.28 page 45):
(5)¶
Choice for the standard deviation¶
We estimate the standard deviation by its sample
counterpart
, evaluated from the sample
:
(6)¶
The estimator of the true standard deviation can
be estimated using the sample standard deviation based
on the sample
.
This is:
where is the sample mean:
Another method is to use the standardized interquartile range ([wand1994] page 60):
where is the quantile function of the
standard normal distribution and
and
are the sample
quartiles at levels 75% and 25% respectively.
The previous estimator is robust against outliers that might be
in the sample.
Plug-in bandwidth selection method (dimension 1)¶
The plug-in bandwidth selection method improves the estimation of the rugosity of the second derivative of the density. Instead of making the Gaussian assumption, the method uses a kernel smoothing method in order to make an approximation of higher derivatives of the density. This method is due to [sheather1991] who used ideas from [park1990]. The algorithm is presented in [wand1994], page 74 under the “Solve the equation rule” name. The implementation uses ideas from [raykar2006], but the fast selection is not implemented.
The equation (3) requires the evaluation of the quantity .
We use the estimator
of
, using a kernel
density estimator of the
-th derivative of the
density.
The estimator is (see [wand1994] page 64):
(7)¶
where is the estimator based on the kernel
K.
Deriving equation (1) leads to:
(8)¶
and then the estimator is defined as:
(9)¶
We note that depends of the parameter h which can be
taken in order to minimize the Asymptotic Mean Square Error (AMSE) criteria
evaluated between
and
.
The optimal parameter h is:
(10)¶
The previous equation states that the bandwidth required
to compute
depends on
.
But to compute
, we need
, etc.
The goal of the method is to break this infinite set of equations at some point
by providing a pilot bandwidth.
The
-stage plug-in bandwidth method uses
different
intermediate bandwidths before evaluating the final one.
In this document, we present the two stage solve-the-equation plug-in method.