From a Local Polynomial to a Weighted Least-Squares Problem
To estimate a regression function near a point, local polynomial regression fits a polynomial using observations near that point, giving more influence to observations with larger kernel weights. This description becomes precise as a weighted least-squares problem: the polynomial coefficients minimize a weighted sum of squared residuals. Once that problem is written in matrix form, the fitted value at the target follows directly from the coefficient vector.
Suppose the observed data are \((X_i,Y_i)\), \(i=1,\ldots,n\), where each \(X_i\) is a scalar predictor and each \(Y_i\) is a response. Fix a target point \(x_0\), a bandwidth \(h>0\), a polynomial degree \(p\geq 0\), and a nonnegative kernel function \(K\). Define the standardized predictor coordinate \(u_i=(X_i-x_0)/h\). The local polynomial uses powers of this coordinate, so its intercept represents the fitted response at \(x_0\).
The weight is often written \(K((X_i-x_0)/h)\). Some conventions include a factor \(1/h\), defining \(K_h(X_i-x_0)=K((X_i-x_0)/h)/h\). For a fixed positive bandwidth, multiplying every weight by the same positive constant multiplies the objective by that constant and does not change its minimizer. Thus the factor \(1/h\) does not affect the fitted coefficients.
Design Matrix, Weights, and Response Vector
For each observation, place the polynomial basis values \(1,u_i,\ldots,u_i^p\) in one row. Put the responses in a vector and the kernel weights on the diagonal of a matrix. This yields the complete weighted least-squares representation.
Writing \(\beta=(\beta_0,\ldots,\beta_p)^\mathsf{T}\), the objective is \((Y-R\beta)^\mathsf{T}W(Y-R\beta)\). The matrix \(R\) is the design matrix for this local fit, \(Y\) is the response vector, and \(W\) records how strongly each observation contributes. Observations with zero kernel weight contribute nothing to the objective.
Invertibility is the condition that makes the coefficient vector uniquely determined by the weighted data. In particular, there must be enough linearly independent polynomial basis rows among observations with positive weights. The result does not require a probability model for the responses: it is an algebraic statement about the stated objective.
Why the Normal-Equation Formula Holds
The formula can be derived by expanding the objective and identifying its minimizer. Let \(Q(\beta)=(Y-R\beta)^\mathsf{T}W(Y-R\beta)\). Because \(W\) is symmetric,
Set \(A=R^\mathsf{T}WR\) and \(b=R^\mathsf{T}WY\). The matrix \(A\) is positive definite when it is invertible: for any nonzero vector \(v\), \(v^\mathsf{T}Av=(Rv)^\mathsf{T}W(Rv)\geq 0\), so \(A\) is positive semidefinite; an invertible positive semidefinite matrix is positive definite. Now let \(\hat\beta=A^{-1}b\). Completing the square gives
The final term is nonnegative and equals zero exactly when \(\beta=A^{-1}b\), since \(A\) is positive definite. Hence this choice uniquely minimizes \(Q\), proving the coefficient formula. At \(X=x_0\), the standardized coordinate is zero, and the fitted polynomial is \(\hat\beta_0+\hat\beta_1(0)+\cdots+\hat\beta_p(0)^p=\hat\beta_0\). This proves the target-value formula as well. \(\square\)
Worked Examples
Worked Example: Degree Zero Gives a Weighted Average
Take \(x_0=0\), \(h=1\), and the triangular kernel \(K(u)=1-|u|\) for \(|u|\leq 1\), with weight zero outside this interval. Observe \((X_i,Y_i)=(-0.5,1),(0,3),(0.5,5)\). Find the degree-zero fit at zero.
For degree zero, each row of \(R\) contains just a 1. The standardized coordinates are \(-0.5,0,0.5\), so the weights are \(0.5,1,0.5\). The coefficient minimizes the weighted sum of squared differences from a single constant. The normal equation is
The total weight is 2, so \(\hat\beta_0=6/2=3\). The degree-zero fitted value at the target is therefore \(\hat m_0(0)=3\).
Worked Example: A Degree-One Fit from Its Matrix
Use \(x_0=0\), \(h=1\), and the same triangular kernel. The observations are \((-0.5,2),(0,1),(0.5,4)\), with standardized coordinates \(-0.5,0,0.5\) and weights \(0.5,1,0.5\). Multiplying all weights by 2 has no effect on the minimizer, so use \(W=\operatorname{diag}(1,2,1)\). Find the degree-one fitted value at zero.
The design matrix has rows \((1,u_i)\). The weighted cross-product and response product are
For example, the upper-right entry is \(1(-0.5)+2(0)+1(0.5)=0\), and the second component of \(R^\mathsf{T}WY\) is \(1(-0.5)(2)+2(0)(1)+1(0.5)(4)=1\). The normal equations give
Thus the fitted local line is \(2+2u\), and its value at the target \(u=0\) is \(\hat m_1(0)=2\).
Worked Example: A Degree-Two Fit with a Uniform Kernel
Take \(x_0=0\), \(h=1\), and \(K(u)=1/4\) for \(|u|\leq2\), zero otherwise. This is a nonnegative kernel with integral one. The four observations are \((-1,1),(0,2),(1,2),(2,5)\). All four receive the same positive weight, so the common factor \(1/4\) can be omitted. Find the degree-two fitted value at zero.
The rows of \(R\) are \((1,u_i,u_i^2)\). With \(W\) taken as the identity matrix after omitting the common factor, summing the powers of the four coordinates gives
The normal equations are \(4\beta_0+2\beta_1+6\beta_2=10\), \(2\beta_0+6\beta_1+8\beta_2=11\), and \(6\beta_0+8\beta_1+18\beta_2=23\). Subtracting half the first equation from the second gives \(5\beta_1+5\beta_2=6\). Subtracting \(1.5\) times the first equation from the third gives \(5\beta_1+9\beta_2=8\). Their difference yields \(4\beta_2=2\), so \(\hat\beta_2=1/2\), then \(\hat\beta_1=7/10\). Substitution into the first equation gives \(4\hat\beta_0+1.4+3=10\), hence \(\hat\beta_0=7/5\). Therefore \(\hat m_2(0)=7/5\).
The Fitted Value as a Linear Combination of Responses
When the weighted design matrix has full column rank, the target fitted value is also a linear combination of the observed responses. Define the row vector of coefficients
Then \(\hat m_p(x_0)=\ell^\mathsf{T}Y=\sum_{i=1}^n\ell_iY_i\). These coefficients depend on the predictor values, target, bandwidth, kernel, and polynomial degree, but not on the observed response values. They are generally not the same as the diagonal kernel weights: kernel weights define the least-squares objective, while \(\ell_i\) describe the resulting fitted value.
To verify this, let \(\mathbf{1}\) denote the \(n\)-vector of ones. The first column of \(R\) is \(\mathbf{1}\), so \(Re_1=\mathbf{1}\). Therefore \(R^\mathsf{T}W\mathbf{1}=R^\mathsf{T}WRe_1\). Substituting into the coefficient sum gives
This identity does not say that each \(\ell_i\) is nonnegative. The kernel weights in \(W\) are nonnegative by assumption, but the coefficients obtained after fitting a polynomial need not be. The identity is instead a consequence of including the constant basis function.
Common Mistakes
- Using the wrong target coordinate. The polynomial is written in \(u_i=(X_i-x_0)/h\), so at the target \(x_0\), \(u=0\). Its fitted value is the intercept, not the sum of all fitted coefficients.
- Confusing \(W\) with the response-combination coefficients. \(W\) contains the kernel weights used in the objective. The final coefficients \(\ell_i\) also depend on the design matrix and need not equal those weights.
- Forgetting the rank condition. If \(R^\mathsf{T}WR\) is singular, the inverse formula is unavailable and the coefficients may not be uniquely determined. Check the positively weighted design before using it.
- Thinking a common weight factor changes the fit. Multiplying every weight by a positive constant changes the objective's scale, not its minimizer.
Check Your Understanding
Use the matrix formulation to answer the following questions.
- For a degree-two fit, what are the entries in the design-matrix row for an observation with standardized coordinate \(u_i\)?
- Why does the fitted value at \(x_0\) equal the intercept when the polynomial is expressed in standardized coordinates centered at \(x_0\)?
- What condition allows the inverse in the weighted least-squares formula to exist?
- For a degree-zero fit, explain why the fitted coefficient is a kernel-weighted average of the responses with positive weights.
- Why does multiplying all kernel weights by the same positive constant leave the fitted coefficients unchanged?