Tutorials › Statistical Learning (Graduate) › Plug-In Bandwidth Selection for Local Polynomials

Local Polynomial Estimation · Tutorial 433 of 989

Plug-In Bandwidth Selection for Local Polynomials

Learn how to turn a pointwise bias–variance formula into a practical local-polynomial bandwidth using pilot estimates and a carefully checked plug-in calculation.

Intermediate 13 min read

What You'll Learn

  • Derive the leading pointwise bias and variance for an interior local linear fit.
  • Obtain the MSE-minimizing bandwidth and identify its curvature and noise inputs.
  • Construct pilot estimates of the regression curvature, predictor density, and conditional variance.
  • See how pilot bandwidths affect derivative estimation and the final plug-in value.
  • Recognize when the usual plug-in formula is unstable or does not apply.

Why a Plug-In Bandwidth Needs Pilot Fits

A local polynomial fit uses a bandwidth to balance two opposing effects: a small bandwidth reduces smoothing bias but uses fewer observations, increasing variance. The pointwise MSE-optimal bandwidth depends on quantities that are usually unknown, including the regression curve's curvature and the conditional noise variance. A plug-in bandwidth replaces those unknown quantities by pilot estimates and substitutes them into the MSE-optimal formula.

To keep the bias coefficient precise, this tutorial derives the formula for an interior local linear fit with a symmetric kernel. Higher-degree fits have their own leading bias coefficients. In random-design regression, those coefficients must account for the design density and its derivatives when they contribute at the relevant order; they cannot always be obtained from a regression derivative alone.

Setup: Let \((X_i,Y_i)\), \(i=1,\ldots,n\), be independent and identically distributed, with \(m(t)=E[Y\mid X=t]\), density \(f(t)\) for \(X\), and conditional variance \(\sigma^2(t)=\operatorname{Var}(Y\mid X=t)\). Fix an interior point \(x\) where \(f(x)>0\). Assume \(m\) is twice continuously differentiable near \(x\), \(f\) and \(\sigma^2\) are continuous at \(x\), and the conditional variance is finite. Take a bounded, symmetric, compactly supported kernel \(K\), normalized so that \(\int K(u)\,du=1\), with finite second moment \(\mu_2(K)=\int u^2K(u)\,du>0\). Assume the local-linear weighted least-squares fit is well-defined with probability tending to one, and that the usual moment and tail conditions for its variance expansion hold.

Pointwise Bias, Variance, and the Oracle Bandwidth

Write \(u_i=(X_i-x)/h\). The local linear fit at \(x\) minimizes \(\sum_{i=1}^n K(u_i)\{Y_i-a-bu_i\}^2\) over \(a,b\); its estimate of \(m(x)\) is the fitted intercept \(\hat m_h(x)=\hat a\). Define \(R(K)=\int K(u)^2\,du\). At an interior point, the leading bias and variance are

$$ \operatorname{Bias}\{\hat m_h(x)\} = B(x)h^2+o(h^2), \qquad B(x)=\frac{\mu_2(K)}{2}m''(x), $$
$$ \operatorname{Var}\{\hat m_h(x)\} = \frac{V(x)}{nh} +o\!\left(\frac{1}{nh}\right), \qquad V(x)=\frac{\sigma^2(x)R(K)}{f(x)}. $$

The local-linear intercept reproduces an exactly linear regression curve, regardless of the local distribution of \(X\). For a curved regression, the leading intercept bias is the local quadratic term after projection onto the constant and linear terms. In the limit, symmetry gives zero first kernel moment, so the coefficient is \(\mu_2(K)m''(x)/2\). Variation in the design density does not add a term of order \(h^2\) to this local-linear bias. This cancellation should not be assumed for other degrees or for a local-constant fit.

The variance coefficient has two components: \(\sigma^2(x)\), the local noise level, and \(1/f(x)\), which reflects how many observations are available near \(x\). The kernel contributes \(R(K)\). Squaring the leading bias and adding the leading variance gives the pointwise MSE approximation

$$ \operatorname{MSE}\{\hat m_h(x)\} \approx B(x)^2h^4+\frac{V(x)}{nh}. $$
Theorem: If \(B(x)\ne0\) and \(V(x)>0\), the positive bandwidth minimizing \(B(x)^2h^4+V(x)/(nh)\) is $$ h_{\mathrm{or}}(x) = \left\{\frac{V(x)}{4B(x)^2n}\right\}^{1/5}. $$ It is called the pointwise oracle bandwidth because it uses the unknown \(B(x)\) and \(V(x)\).

To verify the minimization, differentiate the approximating MSE with respect to \(h>0\). Its derivative is \(4B(x)^2h^3-V(x)/(nh^2)\). Setting this to zero and multiplying by \(h^2\) gives \(4B(x)^2h^5=V(x)/n\), yielding the stated expression. The second derivative is \(12B(x)^2h^2+2V(x)/(nh^3)>0\), so this stationary point is the unique minimum. The two terms balance there: \(V(x)/(nh_{\mathrm{or}})=4B(x)^2h_{\mathrm{or}}^4\). \(\square\)

Worked Example: Oracle Bandwidth with an Epanechnikov Kernel

Suppose \(K(u)=\tfrac34(1-u^2)\) for \(|u|\leq1\), and \(K(u)=0\) otherwise. At the point of interest, let \(m''(x)=2\), \(f(x)=1/2\), and \(\sigma^2(x)=1\). Calculate the oracle bandwidth.

First, \(\mu_2(K)=\tfrac34\int_{-1}^1(u^2-u^4)\,du=\tfrac34(2/3-2/5)=1/5\). Also, \(R(K)=\tfrac9{16}\int_{-1}^1(1-2u^2+u^4)\,du=\tfrac9{16}(2-4/3+2/5)=3/5\).

Thus \(B(x)=(1/5)(2)/2=1/5\), and \(V(x)=1(3/5)/(1/2)=6/5\). Substitution gives \(h_{\mathrm{or}}(x)=\{(6/5)/(4(1/5)^2n)\}^{1/5}=(7.5/n)^{1/5}\). For \(n=1000\), this is approximately \(0.376\). The value is optimal only for the leading pointwise MSE approximation and the specified point \(x\).

Building the Plug-In Estimate

For this local-linear setup, estimate the regression curvature, density, and conditional variance at \(x\). Denote the resulting estimates by \(\widehat{m''}(x)\), \(\hat f(x)\), and \(\hat\sigma^2(x)\). Form

$$ \hat B(x)=\frac{\mu_2(K)}{2}\widehat{m''}(x), \qquad \hat V(x)=\frac{\hat\sigma^2(x)R(K)}{\hat f(x)}, \qquad \hat h_{\mathrm{PI}}(x)= \left\{\frac{\hat V(x)}{4\hat B(x)^2n}\right\}^{1/5}. $$

A standard curvature pilot is a local quadratic fit with its own bandwidth \(b\). In the coordinate \(v=(X_i-x)/b\), fit a quadratic by weighted least squares and write its fitted polynomial as \(\hat\beta_0+\hat\beta_1v+\hat\beta_2v^2\). The curvature estimate is \(2\hat\beta_2/b^2\); the division by \(b^2\) is essential because the polynomial was fitted in a rescaled coordinate. Under sufficient smoothness, positive design density, and regular kernel and moment conditions, a typical consistency regime is \(b\to0\) and \(n b^5\to\infty\). The first condition controls approximation error, while the second allows the derivative estimate's variance to vanish.

The density can be estimated by a kernel density pilot with bandwidth \(a\), for example \(\hat f(x)=(n_fa)^{-1}\sum_{i=1}^{n_f}J((X_i-x)/a)\), where \(J\) integrates to one. Consistency requires \(a\to0\) and \(n_fa\to\infty\), along with continuity of \(f\) at \(x\). For the conditional variance, one may smooth squared residuals \(\{Y_i-\hat m_{\mathrm{pilot}}(X_i)\}^2\) near \(x\). A clean implementation can use an independent pilot sample for \(\hat m_{\mathrm{pilot}}\) and a separate sample for residual smoothing; with consistent regression pilots, a consistent local average of those squared residuals estimates \(\sigma^2(x)\). Finite conditional fourth moments in a neighborhood are a usual sufficient moment condition for this variance estimation.

Result: Suppose \(\hat B(x)\xrightarrow{p}B(x)\), \(\hat V(x)\xrightarrow{p}V(x)\), \(B(x)\ne0\), and \(V(x)>0\). Then \(\hat h_{\mathrm{PI}}(x)/h_{\mathrm{or}}(x)\xrightarrow{p}1\).

Indeed, the ratio is \(\{\hat V(x)/V(x)\}^{1/5}\{B(x)^2/\hat B(x)^2\}^{1/5}\). Consistency gives \(\hat V(x)/V(x)\xrightarrow{p}1\) and \(\hat B(x)/B(x)\xrightarrow{p}1\). The map taking positive ratios to their one-fifth powers is continuous at one, so the product converges in probability to one by the continuous mapping theorem. This proves the result. \(\square\)

The result is a relative-consistency statement: if the pilots consistently estimate the two coefficients and the leading bias is nonzero, their plug-in bandwidth approaches the oracle bandwidth proportionally. It does not promise that a particular finite-sample pilot is accurate. In particular, squaring an imprecise curvature estimate can make the selected bandwidth highly unstable.

Worked Example: Substituting Pilot Estimates

Use the Epanechnikov kernel from the first example. Suppose the pilots give \(\widehat{m''}(x)=1.8\), \(\hat f(x)=0.48\), and \(\hat\sigma^2(x)=1.1\). Calculate the plug-in bandwidth for \(n=1000\).

The estimated bias coefficient is \(\hat B=(1/5)(1.8)/2=0.18\). The estimated variance coefficient is \(\hat V=1.1(3/5)/0.48=0.66/0.48=1.375\).

Therefore \(\hat h_{\mathrm{PI}}=\{1.375/[4(0.18)^2(1000)]\}^{1/5}\). Since \(4(0.18)^2(1000)=129.6\), the quantity inside the braces is \(1.375/129.6\approx0.01061\), and the bandwidth is approximately \(0.403\). The curvature pilot is smaller than the true curvature of 2 in the first example; that reduces the estimated squared bias and raises the selected bandwidth from the oracle value.

Worked Example: A Local-Quadratic Curvature Pilot

Consider a curvature pilot with bandwidth \(b=1\), using five equally weighted observations at rescaled coordinates \(v=-1,-0.5,0,0.5,1\). Suppose their responses are \(y=1+2v+v^2+e\), with perturbations \(e=0.2,-0.1,0,-0.1,0.2\) in that order. Calculate the local quadratic curvature estimate and its plug-in bandwidth if \(\hat f(x)=1/2\), \(\hat\sigma^2(x)=1\), \(K\) is Epanechnikov, and the final sample size is \(n=1000\).

By symmetry, the fitted linear coefficient is determined separately from the constant and quadratic terms. Regressing \(y\) on \(1\) and \(v^2\), the sample mean of \(v^2\) is \((1+0.25+0+0.25+1)/5=0.5\), and its variance with divisor 5 is \(0.425-0.25=0.175\). The mean perturbation is \((0.2-0.1+0-0.1+0.2)/5=0.04\), and the mean of \(v^2e\) is \((0.2-0.025+0-0.025+0.2)/5=0.07\). Thus the covariance of \(v^2\) with the perturbation is \(0.07-(0.5)(0.04)=0.05\). The fitted quadratic coefficient is \(1+0.05/0.175=9/7\), so \(\widehat{m''}(x)=2(9/7)/b^2=18/7\).

The corresponding bias estimate is \(\hat B=(1/5)(18/7)/2=9/35\), and \(\hat V=(1)(3/5)/(1/2)=6/5\). Hence \(\hat h_{\mathrm{PI}}=\{(6/5)/[4(9/35)^2(1000)]\}^{1/5}\approx0.340\). This calculation also shows why the pilot bandwidth's scale matters: the fitted coefficient \(9/7\) is on the \(v\)-scale, so the curvature in the original \(X\)-scale is \(2(9/7)/b^2\), not simply \(2(9/7)\) for a general \(b\).

Choosing Pilots and Interpreting the Result

The final bandwidth and the pilot bandwidths solve different problems. The final \(h\) smooths the regression estimate at the desired point. The derivative pilot \(b\) estimates curvature, and derivative estimation is especially sensitive to noise: its variance typically has order \(1/(n b^5)\), rather than the order \(1/(n b)\) associated with estimating a function value. If \(b\) is too small, the curvature estimate is noisy; if it is too large, local polynomial approximation error can dominate. Density and variance pilots also have their own bandwidths and consistency requirements. A single numerical bandwidth should not automatically be reused for every pilot task.

The plug-in formula applies when the displayed \(h^2\) bias is genuinely the leading bias. If \(m''(x)=0\), then \(B(x)=0\) and the formula divides by a quantity tending to zero; the next nonzero bias term may determine a different rate and requires its own valid expansion. Likewise, a curvature estimate near zero can produce an extremely large or erratic bandwidth. In practice, report the pilot estimates alongside the selected bandwidth and inspect whether the leading-bias assumptions are plausible.

  • Mistake: Use a local-constant bias formula for a local-linear fit, or assume a higher-degree bias coefficient is always just a regression derivative times a kernel moment. Correction: Derive the coefficient for the estimator and design setting being used; density-derivative terms can enter random-design expansions.
  • Mistake: Use the local-quadratic coefficient on the rescaled coordinate directly as \(m''(x)\). Correction: If the coordinate is \(v=(X-x)/b\), multiply the fitted quadratic coefficient by \(2/b^2\).
  • Mistake: Treat the plug-in value as universally optimal or stable. Correction: It estimates a pointwise leading-MSE optimum and depends on consistent pilots and a nonzero leading bias coefficient.
Key takeaway: For an interior local-linear fit with nonzero curvature, estimate \(B(x)=\mu_2(K)m''(x)/2\) and \(V(x)=\sigma^2(x)R(K)/f(x)\), then substitute them into \(\{V(x)/(4B(x)^2n)\}^{1/5}\). The quality of the result depends on pilots appropriate to each quantity.

Check Your Understanding

Work through these questions using the assumptions and formulas above.

  1. Why does the local-linear leading bias coefficient in this setup not include a term involving \(f'(x)\)? Why should this not be generalized automatically to other fits?
  2. For a local-quadratic pilot fitted in \(v=(X-x)/b\), what transformation converts its quadratic coefficient into a curvature estimate on the original \(X\)-scale?
  3. Explain why the variance coefficient \(V(x)\) increases when the design density at \(x\) decreases, with the noise variance and kernel held fixed.
  4. What conditions on \(\hat B(x)\) and \(\hat V(x)\) imply that the plug-in bandwidth divided by the oracle bandwidth converges in probability to one?
  5. What is the problem with applying the usual fifth-root plug-in formula when \(m''(x)=0\)?
Clinical Biostats