Why Bandwidth Should Vary Near a Boundary
A single bandwidth must compromise between bias and variance everywhere: wide windows average more observations but blur local structure, while narrow windows preserve detail at the cost of greater variability. That compromise can be wasteful for level-set recovery. If the density is smoother near one part of the target boundary than another, the two regions need not use the same smoothing scale.
The objective is not simply to estimate the density well throughout the domain. Errors matter especially where the density is near the threshold: an error there can move the estimated boundary. We therefore distinguish local density accuracy from the geometric conditions that convert it into boundary accuracy. Throughout, the target is the superlevel set at a fixed threshold \(\lambda\),
Here \(f\) is a density on a compact domain, and the observations \(X_1,\ldots,X_n\) are independent with density \(f\). The earlier material on level-set losses and gradient separation motivates why both set error and boundary displacement require attention; the focus here is how spatially varying smoothing interacts with that geometry.
Local Smoothness and a Spatial Bandwidth
We use orders above one because the boundary argument below assumes a nonzero gradient, and because a symmetric second-order kernel can then have bias of order \(h^{\beta_j}\). The kernel \(K\) is assumed bounded, compactly supported, integrable, and symmetric, with \(\int K(u)\,du=1\) and \(\int uK(u)\,du=0\). The location-dependent kernel estimator is
where the bandwidth \(h(x)>0\) may change with location. For a finite collection of boundary patches \(U_1,\ldots,U_J\), write \(h_j\) for the bandwidth used on patch \(U_j\). A smooth transition between bandwidths, or an overlapping patch construction, avoids artificial jumps in \(\widehat f\).
Worked Example: Bias at a Boundary With Hölder-Smooth Gradient
Consider a one-dimensional density that, near \(x=0\), has the form \(f(x)=\lambda+gx+c|x|^{3/2}\), where \(g>0\) and \(c>0\). This is a local profile; it can be joined to a density away from zero. The point \(0\) is a level boundary because \(f(0)=\lambda\), and the derivative there is \(g\), so the crossing is not flat.
Use the uniform kernel \(K(u)=1/2\) for \(|u|\leq1\) and zero otherwise. At \(x=0\), the expectation of the kernel estimator is \[ E[\widehat f(0)]=\frac12\int_{-1}^1 f(-hu)\,du. \] The linear term \( -ghu\) integrates to zero by symmetry. The remaining nonconstant term contributes \[ \frac{c h^{3/2}}{2}\int_{-1}^1 |u|^{3/2}\,du =\frac{c h^{3/2}}{2}\left(2\int_0^1u^{3/2}\,du\right) =\frac{c h^{3/2}}{2}\left(\frac45\right) =\frac{2c}{5}h^{3/2}. \] Thus the bias at the boundary is \(2ch^{3/2}/5\), not a first-order term in \(h\). The nonzero slope \(g\) still controls how a density error moves the boundary; the \(3/2\)-order smoothness controls the smoothing bias.
Local Error and Bandwidth Balance
The next calculation isolates the two competing terms. In each patch, assume the kernel window remains inside a region where the local smoothness condition holds. Also assume a simultaneous stochastic bound over the candidate bandwidths and locations under consideration:
This is a high-probability condition, with a constant \(C\) independent of \(x\) and the candidate bandwidth. It can be obtained under standard bounded-kernel and complexity conditions for the indexed kernel class; for data-selected bandwidths, the bound must hold simultaneously over all candidates before selection. We will use bandwidths satisfying \(nh(x)^d\geq \log n\), so the second term is no larger in order than the first.
To verify the bound, change variables in the expectation to obtain \(E[\widehat f(x)]=\int K(u)f(x-h_ju)\,du\). Local smoothness gives \(f(x-h_ju)=f(x)-h_j\nabla f(x)^\mathsf{T}u+R(x,u)\), with \(|R(x,u)|\leq L_j h_j^{\beta_j}\|u\|^{\beta_j}\). The constant term integrates to \(f(x)\), and the linear term integrates to zero because \(\int uK(u)\,du=0\). Taking absolute values of the remainder integral proves the bound.
Combining this bias bound with the stochastic condition gives, on patch \(j\), a local error of order \(h_j^{\beta_j}+\sqrt{\log n/(nh_j^d)}\). Equating the two terms yields the oracle bandwidth and error scale:
The constants can depend on the local smoothness and kernel. The displayed rates concern local uniform error on the patches under the stated simultaneous bound; they do not, by themselves, establish boundary recovery. That requires a geometric argument.
Worked Example: Different Oracle Scales on Two Boundary Patches
Suppose \(d=2\), and two boundary patches have smoothness orders \(\beta_1=2\) and \(\beta_2=3/2\). For an illustration, set \(t=\log n/n=2^{-10}\). On the smoother patch, \[ h_1=t^{1/(2(2)+2)}=t^{1/6}=2^{-5/3}, \qquad r_1=t^{2/6}=2^{-10/3}. \] On the less smooth patch, \[ h_2=t^{1/(2(3/2)+2)}=t^{1/5}=2^{-2}=\frac14, \qquad r_2=t^{(3/2)/5}=t^{3/10}=2^{-3}=\frac18. \] The smoother patch uses a wider bandwidth and has a smaller error scale: \(2^{-10/3}\) is approximately \(0.099\), less than \(1/8=0.125\). These are rate calculations with constants suppressed, not exact finite-sample error guarantees.
When Density Accuracy Gives Boundary Accuracy
A small density error moves a regular boundary by a comparable amount only when the density crosses the threshold at a nonzero rate. The following result states that conversion locally. Assume each patch \(U_j\) covers a boundary segment and a surrounding tube. In that tube, suppose the boundary is regular, the gradient has norm at least \(g_j>0\), and the density changes monotonically along the normal direction with derivative magnitude at least \(g_j\). Assume also that outside the tubes there is a positive gap from \(\lambda\), so no other part of the domain can create a spurious estimated boundary. Let \(\widehat G_\lambda=\{x:\widehat f(x)\geq\lambda\}\), with \(\widehat f\) continuous.
Proof. Let \(z\) be a true boundary point in patch \(j\), and move along its normal by distance \(s=2\varepsilon_j/g_j\) to either side. By the assumed normal derivative bound, the true density differs from \(\lambda\) by at least \(g_js=2\varepsilon_j\) at each such point, with opposite signs on the two sides. Since the estimation error is at most \(\varepsilon_j\), the estimated density is above \(\lambda\) on one side and below it on the other. Continuity and the intermediate value theorem therefore give an estimated boundary point between them, at distance at most \(s\) from \(z\).
Conversely, let \(y\) be an estimated boundary point in the tube. Continuity gives \(\widehat f(y)=\lambda\), so \(|f(y)-\lambda|\leq\varepsilon_j\). The normal derivative bound implies that the distance from \(y\) to the true boundary is at most \(\varepsilon_j/g_j\), which is no larger than \(s\). The density gap outside the tubes excludes estimated boundary points there. Taking the largest patchwise bound proves the Hausdorff claim. \(\square\)
In applications, one may take \(\varepsilon_j\) to be a constant multiple of \(r_j\) on a high-probability event. The theorem then gives patchwise displacement of order \(r_j/g_j\). The worst patch controls the global Hausdorff error. This conclusion needs the error bound in a tube, not just at points exactly on the boundary.
Worked Example: Converting a Local Error Into Boundary Displacement
Suppose a one-dimensional density crosses \(\lambda\) at \(x_0\), with derivative at least \(g=0.8\) in magnitude throughout a neighborhood. If the estimated density has error at most \(\varepsilon=0.02\) in that neighborhood, the theorem's displacement bound is \[ \frac{2\varepsilon}{g}=\frac{2(0.02)}{0.8}=0.05. \] Indeed, at points \(0.05\) to either side of the true boundary, the density differs from \(\lambda\) by at least \(0.8(0.05)=0.04\). An error of \(0.02\) cannot reverse either sign, so continuity forces an estimated crossing between those points. The bound is conservative: the converse direction gives distance at most \(\varepsilon/g=0.025\) for any estimated crossing in the neighborhood.
What Adaptation Can and Cannot Promise
The oracle calculation assumes that the local smoothness order is known, or that the bandwidth procedure has already been shown to attain comparable local errors. Knowing only that smoothness varies does not automatically produce an adaptive estimator. A data-driven selector must control errors simultaneously across locations and candidate bandwidths; a selector chosen from the same data without such control can select an overly small bandwidth in a noisy region or an overly large one near a boundary feature.
One common approach is a Lepski-type comparison across a collection of bandwidths: at each location, compare estimates at different scales and choose a scale whose estimates remain compatible with those at finer scales, using a stochastic threshold. To justify the oracle rates, the comparison must account for all candidates, the local bias assumptions must hold over each selected kernel window, and the resulting bandwidth field must preserve the continuity or patchwise coverage needed by the boundary argument. These are conditions to verify, not consequences of the rate balance alone.
Worked Example: The Cost of Using the Rough-Patch Bandwidth Everywhere
Continue with \(d=2\), \(t=2^{-10}\), and the two smoothness orders \(2\) and \(3/2\). If the bandwidth \(h=1/4=t^{1/5}\), chosen for the rougher patch, is also used on the smoother patch, its stochastic term is \[ \sqrt{\frac{t}{h^2}} =\sqrt{\frac{2^{-10}}{2^{-4}}} =\sqrt{2^{-6}}=2^{-3}=\frac18. \] Its bias on the smoother patch is of order \(h^2=1/16\), so the combined error scale is of order \(1/8\). The smooth-patch oracle scale is \(2^{-10/3}\), approximately \(0.099\), which is smaller. The common rough-patch bandwidth is not invalid; it simply gives away some accuracy on the smoother region. Conversely, choosing the smoother-patch bandwidth everywhere may leave too much variance in rough regions.
Common Mistake: Confusing Local Rates With a Global Guarantee
A tempting but incorrect argument is: “The bandwidth is optimal at every patch, so the estimated level set has the best boundary rate everywhere.” The local balance only controls density error under its own smoothness, concentration, and window conditions. Boundary recovery also needs gradient separation, enough accuracy in a neighborhood, and protection against threshold crossings elsewhere. Moreover, a single Hausdorff rate is governed by the least favorable boundary patch, not by an average of the smooth-patch rates.
The correction is to make each step explicit: establish simultaneous local error bounds for the selected bandwidths; ensure the kernel windows stay within regions where their smoothness assumptions hold; check gradient separation and the away-from-boundary density gap; then apply the geometric displacement argument. If the boundary is nearly flat in the sense that its gradient is small, the factor \(1/g_j\) can dominate even when the density estimator has a favorable rate.
Check Your Understanding
Use the assumptions and distinctions developed above.
- Why does a symmetric kernel remove the first-order Taylor term in the local bias calculation?
- For local smoothness order \(\beta\), derive the bandwidth exponent by balancing \(h^\beta\) with \(\sqrt{\log n/(nh^d)}\).
- If the density error near a boundary patch is at most \(\varepsilon\) and the normal derivative is bounded below by \(g\), what displacement bound follows from the theorem?
- Why does a local density error bound at boundary points alone not establish the two-sided Hausdorff conclusion?
- Name two additional requirements a data-driven bandwidth selector must meet before its local rate calculations can be used for boundary recovery.