Fast rate of a nearest neighbor estimate for a global parameter
Author: Yen-Chi Chen (University of Washington) Date: 07/08/2026
Quick summary
While kNN methods estimate a local parameter at a slow rate, it can estimate a global parameter at a much faster rate (even close to n-rate).
We show an example of a fast 1NN estimate for θ=E(m2(X)), where m(x)=E(Y∣X=x) is the regression function; see this section.
The rate improvement also occurs for estimating parameters like η=E(em(X)) that is a smooth transformation of m(X); see this section.
However, the improvement will not occur if the transformation is non-smooth like ρ=E(I(∣m(X)∣>0.5)); see this section.
Local versus global parameter
We consider a simple nonparametric regression model where our data consists of IID random variables (X1,Y1),⋯,(Xn,Yn)
from some unknown distributions such that Xi∈Rd.
We further assume the following data generating process: Yi=m(Xi)+ϵi,
where Xi⊥ϵi and ϵ1,⋯,ϵn are IID mean 0 noises with variance Var(ϵi)=σ2<∞.
It is well-knonwn that we cannot estimate the local parameterm(x) at a very fast rate unless it is super smooth. Roughly speaking, if m(x) has bounded s-times derivatives, the fastest rate that we can achieve is m^(x)−m(x)=OP(n−s/(2s+d)).
The kNN estimator achieves this rate with a good choice of k∼n−s/(2s+d).
Note that conventional choice is s=2 since we often assume that the function m(x) is twice differentiable.
Now we consider estimating a global parameter θ=E(m2(X)).
This parameter is often of interest due to its relation to the variance σ2=E((Y−m(X))2).
How to estimate θ in a nonparametric setting?
1-NN estimator
It turns out that a simple and accurate estimator is the 1-NN estimator θ^n=n1i=1∑nYiYN(i),
where N(i)=argminj=i∥Xj−Xi∥
is the index of the i-th observation.
Convergence rate
Here is an interesting fact about θ^n: It is very accurate in the sense that its convergence rate is (ignoring some logn factors) θ^n−θ=OP(n1+n−1/d)
when m is Lipschitz continuous.
Namely, we actually achieve a parametric rate when d≤2!
The above rate has two components:
Variance. The n1 is from the variance of the estimator, which is the conventional rate.
Bias. The second component n−1/d is the bias. If you are familiar with the kNN theory, you may notice that this is exactly rate of the distance between ∥Xi−XN(i)∥. In fact, if we use k-NN rather than 1-NN, it remains at the same rate as long as k does not scale with respect to the sample size n.
Convergenace rate
Here is how we obtain the above rate. First, observed that Yi=m(Xi)+ϵi,YN(i)=m(XN(i))+ϵN(i)
so as long as m is Lipschitz continuous, we have m(XN(i))=m(Xi)+δi,δi=OP(∥Xi−XN(i)∥)=OP(n−1/d).
Putting this back into the estimator θ^n, we obtain θ^n=n1i=1∑nYiYN(i)=n1i=1∑n(m(Xi)+ϵi)(m(Xi)+δi+ϵN(i))=n1i=1∑nsignalm2(Xi)+biasm(Xi)δi+noiseϵN(i)Yi+ϵiYN(i).
Clearly, the signal component n1∑i=1nm2(Xi) results in a n-consistent estimator of θ. So we just need to control the remaining quantities.
Bias component
Since it is well-known that δi=OP(n−1/d), we immediately have n1i=1∑nm(Xi)δi=OP(n−1/d)
under very mild conditions of m(x) and the underly density function of the covariate pX.
Noise component (part of the variance)
The remaining quantity Vˉn=n1i=1∑n=ViϵN(i)Yi+ϵiYN(i)
behaves like average of noises and under proper moment conditions of ϵi, we have Var(Vi)=σV2<∞.
However, this is NOT enough to argue that Var(Vˉn)=OP(n−1/2) because V1,⋯,Vn are dependent due to the 1NN component.
Formally, we have Var(Vˉn)=n21i=1∑nVar(Vi)+n21i=j=1∑nCov(Vi,Vj).
The first variance is controlled as we have mentioned. The tricky part is the second component the covariance.
Kissing number
Fortunately, here is a useful geometry quantity called kissing number in d-dimensional (Euclidean) space.
The kissing number offers an upper bound on how many 1-NN that any given point can have in Rd (and it can be generalized to k-NN as well).
Simply put, for any sets of points in Rd and we create a 1-NN graph, i.e., we add an edge between Xi,Xj if one is an 1-NN to the other, the maximal degree of any point is bounded by a constant Kd known as the kissing number. This constant is purely geometry property that only depends on the dimension d and not the sample size (number of points).
To see how this occurs, consider a given point X0 and try to place points around it such that X0 is the 1NN of all the points you want to place near X0. If you have place X1, then X2 cannot be in the ball B(X1,∥X1−X0∥) otherwise X2's 1NN will be X1, not X0 (or X1's 1NN will be X2, not X0). Therefore, if you have placed X1,⋯,Xk, the next point Xk+1 will be confined to a much smaller region to ensure X0 is the 1NN point. Evetually, the entire space will be filled up and there is no way you can place any more points whose 1-NN is X0.
Using the idea of kissing number and the fact that Vi,Vj will be correlated only if {Xi,XN(i)}∩{Xj,XN(j)}=∅, we realize that the set {j:Cov(Vi,Vj)=0} has at most Cd≤2Kd elements. So most pairs Cov(Vi,Vj)=0, and we conclude that n21i=j=1∑nCov(Vi,Vj)≤n22nKd×σV2=O(n−1),
where σV2<∞ is just some constant. Therefore, we conclude that Var(Vˉn)=O(n−1)
and hence θ^n−θ=OP(n1+n−1/d).
Estimating higher-order moments
The same estimator can be applied to cases where we are interested in the average of an L-th local moment. Specifically, consider θL=E(mL(X)).
We can use a (L−1)-NN estimator: θ^L=n1i=1∑nYiℓ=1∏L−1YNL−1(i),
where NL−1(i) is the indices of the (L−1)-NN of Xi.
Using the same derivation, the convergence rate of θ^L remains the same: θ^L−θL=OP(n1+n−1/d).
Polynomial transformation
If we are interestinf θf=E(f(m(X))) such that f is a polynomial function, then the above kNN trick applies with k to be the highest order of the polynomial minus 1.
For a concreate example, suppose we are interested in estimating μ=E((m2(X)−5)2)=E(m4(X)−10m2(X)+25), we can apply a 3NN estimator of E(m4(X)) and a 1NN estimator of E(m2(X)) to obtain the estimate of μ.
Another example of a slightly faster rate: η=E(em(X))
Now we consider the problem of estimating η=E(em(X)). Since the exponential is a inifinite-order polynomial, the above fixed k approach is not applicable so we have to consider k=kn→∞ as n→∞.
Consider a simple plug-in estimator: η^k=n1i=1∑nem^k(Xi).
Rate improvement for global parameter
When m(x) is twice differentiable, η^k−η=OP(n−s/(s+d)),
which is (slightly) faster than the rate of estimating the local parameter m^k(x)−m(x)=OP(n−s/(2s+d)).
How does the rate improvement occur?
To see how the rate improve occurs, consider the orcale estimator η~=n1i=1∑nem(Xi).
Clearly, η~−η=OP(n1).
But this estimator and the kNN estimator are similar via a Taylor expansion: em^k(Xi)−em(Xi)≈em(Xi)(m^k(Xi)−m(Xi))+21em(Xi)(m^k(Xi)−m(Xi))2.
(linear): key improvement of the rate (a.k.a. variance collapse). This part is the key improvement of the convergence rate. Roughly speaking, the estimator m^k(Xi)=k1j∈Nk(i)∑Yj=k1j∈Nk(i)∑m(Xj)+ϵj.
So the i-th term in (linear) has a bias at rate Bi=k1j∈Nk(i)∑em(Xi)∣m(Xj)−m(Xi)∣=OP((nk)s/d)
and the variance k1∑j∈Nk(i)em(Xi)ϵj.
The average does not change the bias rate and the variance part has an interesting phenomenon: n1i=1∑nj∈Nk(i)∑em(Xi)ϵj=n1i=1∑nWiϵj,
where Wi is related to tthe number of times Xi is within k-NN of other observation Xj and the corresponding em(Xj). Again, due to the geometry (similar to the kissing number), each point can only appear up to certain times in others' kNN, so this weight will be upper bounded.
Thus, the average n1∑i=1nWiϵj leads to a rate OP(n1). Putting these together, we conclude that (linear)=OP(n1+(nk)s/d).
(MSE): the conventional rate. The second term is like a sample version of the mean square error (MSE). So it is at the conventional rate of the MSE (MSE)=OP(k1+(nk)2s/d)
Therefore, the dominating error is the bias from (linear) and the variance from (MSE), which corresponds to the rate η^k−η=η^k−η~+η~−η=OP(n1+k1+(nk)s/d)
and under the optimal choice of k∼ns/(s+d), we obtain the rate η^k−η=OP(n−s/(s+d)).
von Mises exapnsion
The above derivation is known as the von Mises expansion. In short, the von Mises expansion uses the fact that when estimating a global parameter, we have a summation/integration process over each Xi, which offers a way to reduce the stochastic errors of a local estimator due to the averaging process.
Generalization to other smooth transformation
The von Mises expansion can be generalized to other case of E(f(m(X))) for smooth f. As long as the function f is smooth in the sense that we can apply a Taylor expansion, we are able to improve the convergence rate via the same von Mises expansion.
An example of no improvements: ρ=E(I(m(X)>0.5))
When the parameter of interest is not a polynomial functional, this kNN trick fails and we have to retreat to the conventional local estimator, although we may still have a fast rate with some other conditions.
Consider the quantity ρ=E(I(m(X)>0.5)).
This is a common quantity in binary classification, where it measures the predictive probability of class 1 if we convert the regression model into a classifier.
No rate improvement
Unfortunately, the above kNN tricks cannot be applied to ρ because the transformation I(m(x)>0.5) is non-smooth (it is actually discontinuous). So the convergence rate for an estimator ρ^k=n1∑i=1nI(m^k(Xi)>0.5) will be ρ^k−ρ=OP(n−s/(2s+d))
when the function m is s-times differentiable.
To see this, if you pick any fixed k, say k=5, the kNN estimator m^k has a non-vanishing variance. So for any x with m(x)≈0.5, this non-vanishing variance could push it up or down the critical threshold 0.5, leading to a non-vanishing error regardless of the sample size. Therefore, we have to set k to slowly increase with respect to the sample size to achieve consistency. Moreover, the Taylor expansion method in the previous section is not applicable since the indicator function is not differentiable.
Improving rate by Tsybakov's margin condition
Note that in this scenario, we may improve the convergence rate via the Tsybakov's margin condition:
Tsybakov's margin condition
We assume that P(∣m(X)−0.5∣≤0.5)<A0⋅ϵα for some constants A0 and α.
α=1: the conventional scenario: m(x) and pX(x) is smooth and pX(x)≥p0>0 around some part of the decision boundary D={x:m(x)=0.5}.
α>1: we need to have pX(x)=0 on the decision boundary D and the density slowly increase (rate depends on α) when we are away from D.
Under Tsybakov's margin condition, the convergence rate of an k-NN estimator of ρ is ρ^k−ρ=OP(n−2s+dsα)
when we choose k∼ns/(2s+d).
Rate comparison for estimating a global parameter
Now we see three regimes of the convergence rate. To put everything in the same condition, we consider m to be only Lipschitz smooth. A sufficient condition is m to have a uniformly bounded derivative. So we can view this as the case of s=1.
Recall that the convergence rate for estimating a local parameter m(x) is m^k(x)−m(x)=OP(n−1/(2+d))
when we choose k∼n1/(2+d).
In this case, we can see three convergence rates:
Ultra fast regime: fixed k. For estimating global parameter that is the expectation of a polynomial of m(X), we have rate θ^n−θ=OP(n−1/2+n−1/d).
In this case, we achieve the parametric rate when d≤2.
Fast regime: quickly diverging k. For estimating a global parameter that is the expecatation of a smooth transformation of m(X), we have a rate η^k−θ=OP(n−1/2+n−1/(1+d))
when we choose k∼n1/(1+d). We can achieve parametric rate when d=1.
Regular regime. If the global parameter involves a non-smooth transformation of m(X), we may not be able to obtain any rate improvement relative to the local parameter: ρ^k−ρ=OP(n−1/2+n−1/(2+d))
when we choose k∼n1/(2+d). We cannot acheive parametric rate in this scenario.