Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SJ bandwidth estimation

Introduction

Kernel Density Estimation (KDE) is a powerful non-parametric technique used to estimate the probability density function of a random variable without relying on rigid structural assumptions (such as the bell curve of a Normal distribution). The behavior of a KDE model depends primarily on two components: the kernel function-typically a standard Gaussian distribution that assigns local probability weights based on distance, and the bandwidth parameter hh.

The bandwidth hh acts as a crucial smoothing parameter that dictates sensitivity of the model. If hh is too small, the estimator overfits the data, creating a noisy, wiggling curve. Conversely, if hh is too large, the estimator undersmooths (underfits) the data, washing away genuine structural details into a flat, uninformative curve Scott, 2012.

While numerous methodologies have been developed to optimize hh, the plug-in approach by Sheather & Jones (1991) remains a benchmark standard, reliably minimizing the Asymptotic Mean Integrated Squared Error (AMISE) across a wide array of complex, non-parametric distributions Eidous et al., 2010.

Workflow

Initially, the input data vector XX is partitioned into discrete bins to calculate a bin-step density (detailed in Bin-step density). This binning strategy dramatically reduces the computational cost of evaluating the double summations required by the pilot bandwidth estimators when performing the secondary bandwidth α\alpha estimation detailed in the secondary bandwidth (α\alpha) estimator.

From that, the roughness functionals are estimated, allowing the optimal primary bandwidth hh to be found (as described in the primary bandwidth hh) by solving the derivative of the AMISE equation, the core metric evaluating the accuracy of estimation. The underlying mathematical theories are detailed in the boxes below.

Bin-step density

First, the data is partitioned into NN discrete bins (the default is 1000) to determine the individual bin frequencies (bkb_k, where 0kN10 \le k \le N-1). These frequencies are used to efficiently compute the total number of data point pairs at each specific bin-step.

ci=k=iN1bkb(ki)c_i = \sum_{k=i}^{N-1}{b_{k}b_{(k-i)}}

Equation (10) measures total density of unique pairs (cic_i) between 2 bins with the ii-bin distance.

c0=k=0N1(bk2)=k=0N1bk(bk1)2c_0 = \sum_{k=0}^{N-1}{ b_k \choose 2 } = \sum_{k=0}^{N-1}{\frac{b_k (b_k-1)}{2}}

For the baseline case where the distance between bins is zero (i=0i = 0), the value c0c_0 represents the pairs residing within the exact same bin, described in Equation (11).

Secondary bandwidth (α\alpha) estimator

α^(h)=1.357(S^D(a)T^D(b))1/7h5/7\hat{\alpha}(h) = 1.357 \cdot \left( \frac{\hat{S}_D(a)}{\hat{T}_D(b)} \right)^{1/7} \cdot h^{5/7}

Equation (12) is transformed from equation (9), where both kernel function KK and LL follows Probability Density Function (PDF) of Normal Distribution. Additionally, R(f)R(f'') and R(f)R(f''') are estimated to S^D(a)\hat{S}_D(a) and T^D(b)\hat{T}_D(b) perspectively using the method of Jones & Sheather (1991) with the heuristic pilot bandwidth aa and bb. The practical computation of S^D(a)\hat{S}_D(a) and T^D(b)\hat{T}_D(b) details in The first pilot bandwidth and The second pilot bandwidth correspondently.

The first pilot bandwidth

a=0.920λ^N1/7a = 0.920 \cdot \hat{\lambda}N^{-1/7}

By Equation (8), assuming both the kernel function LL and the true density function ff follow normal distributions, the heuristic bandwidth aa for bias optimization is obtained as Equation (13) with λ^\hat{\lambda} is the estimated interquartile.

S^D(a)=1N(N1)a5i=0N1[ciϕiv(dia)]\hat{S}_D(a) = \frac{1}{N(N-1)a^5} \sum_{i=0}^{N-1} \left[ c_i \cdot \phi^{\text{iv}}\left(\frac{d \cdot i}{a}\right) \right]

The pilot roughness estimator S^D(a)\hat{S}_D(a) of Equation (12) is estimated following Equation (14), which originates from Equation (5). Practically, due to using bin-step density (cic_i) with the bin width dd calculated while dividing bins, it reduces complexity from O(k2)O(k^2) (kk is the data size) to O(N)O(N) comparing to the theoretical formula.

ϕiv(t)=12πet2/2(t46t2+3)\phi^{\text{iv}}(t) = \frac{1}{\sqrt{2\pi}} e^{-t^2/2} \left( t^4 - 6t^2 + 3 \right)

In Equation (14), ϕiv(t)\phi^{\text{iv}}(t) is the 4-th derivative of the Normal Distribution PDF. The expansion using the Hermite polynomials is shown by Equation (15).

The second pilot bandwidth

b=0.912λ^N1/9b = 0.912 \cdot \hat{\lambda}N^{-1/9}

Simmilarly, R(f)R(f''') is estimated and canceled out bias by using specific bandwidth bb. Subsequently, assuming both kernel functions follow normal scale model, the heuristic bandwidth bb is computed following Equation (16).

{T^D(b)=1N(N1)b7i=0N1[ciϕvi(dib)]ϕvi(t)=12πet2/2(t615t4+45t215)\begin{cases} \begin{aligned} \hat{T}_D(b) = \frac{1}{N(N-1)b^7} \sum_{i=0}^{N-1} \left[ c_i \cdot \phi^{\text{vi}}\left(\frac{d \cdot i}{b}\right) \right] \\ \phi^{\text{vi}}(t) = \frac{1}{\sqrt{2\pi}} e^{-t^2/2} \left(t^6 - 15t^4 + 45t^2 - 15\right) \end{aligned} \end{cases}

Likewise to the first pilot bandwidth, the component T^D(b)\hat{T}_D(b) estimated for R(f)R(f''') in Equation (12) is computed by Equation (17). Note that ϕvi(t)\phi^{\text{vi}}(t) is the 6-th derivative of the PDF of Normal Distribution.

Primary bandwidth (hh) computation

[2NπS^D(α^(h))]1/5h=0\left[ 2N\sqrt{\pi} \hat{S}_D( \hat{\alpha}(h) ) \right]^{-1/5} - h = 0

Ultimately, the optimal bandwidth hh is found by Equation (18), which originates from Equation (2) with KK following normal scale model and the substitution of R(f)R(f'') by S^D(α^(h))\hat{S}_D( \hat{\alpha}(h) ). Noticeably, data size nn is replaced by the number of bins NN.

Finally, Equation (18) is solved using Brent’s method Brent, 2013 to find optimized bandwidth hh.

Summary

Overall, the Sheather-Jones method optimizes the bandwidth parameter (hh) by minimizing the AMISE. The primary challenge of this approach lies in estimating the unknown curvature of the true underlying density function ff. This is achieved by utilizing a pilot estimation step (a secondary KDE) with an auxiliary bandwidth, which effectively cancels the asymptotic biases of the roughness estimator.

In practice, the implementations utilize a linear binning technique to drastically reduce the computational complexity. Furthermore, while Sheather & Jones (1991) originally outlined a Newton-Raphson framework to solve for the final bandwidth, the practical implementation employs Brent’s method. This numerical root-finding approach guarantees convergence and computational robustness when solving Equation (18).

However, the primary theoretical drawback of this method is its circularity: it relies on the assumption that the real unknown density function ff can be approximated well enough by an initial normal-scaled kernel estimator.

References
  1. Scott, D. W. (2012). Multivariate Density Estimation and Visualization. In J. E. Gentle, W. K. Härdle, & Y. Mori (Eds.), Handbook of Computational Statistics: Concepts and Methods (pp. 549–569). Springer Berlin Heidelberg. 10.1007/978-3-642-21551-3_19
  2. Sheather, S. J., & Jones, M. C. (1991). A Reliable Data-Based Bandwidth Selection Method for Kernel Density Estimation. Journal of the Royal Statistical Society Series B: Statistical Methodology, 53(3), 683–690. 10.1111/j.2517-6161.1991.tb01857.x
  3. Eidous, O. M., Marie, M. A. A. S., & Ebrahem, M. H. B. A.-H. (2010). A Comparative Study for Bandwidth Selection in Kernel Density Estimation. Journal of Modern Applied Statistical Methods, 9(1), 263–273. 10.22237/jmasm/1272687900
  4. Jones, M. C., & Sheather, S. J. (1991). Using Non-Stochastic Terms to Advantage in Kernel-Based Estimation of Integrated Squared Density Derivatives. Statistics & Probability Letters, 11(6), 511–514. 10.1016/0167-7152(91)90116-9
  5. Brent, R. P. (2013). Algorithms for minimization without derivatives. Courier Corporation.