Boundary bias of local constant regression (source code)

= Boundary bias of local constant regression
{title2=$\operatorname{Bias}(\widehat m(0))\asymp h$}

A <local constant estimator> reproduces constants but need not reproduce an affine <regression function> near a support boundary. Let $x_i=i/n$, take $0<h\leq1$ and the <regression kernel> $K=\mathbf1_{[-1,1]}$, and suppose $m(x)=x$. At target zero, the noiseless <Nadaraya–Watson estimator> averages $i/n$ for $1\leq i\leq k=\lfloor nh\rfloor$. Whenever $k\geq1$, its exact fitted value is
$$
\frac1k\sum_{i=1}^k\frac in=\frac{k+1}{2n}.
$$
Since $m(0)=0$, this is the <bias of an estimator> when observation errors have zero <expected value>. Under $h\to0$ and $nh\to\infty$, it is asymptotic to $h/2$. The one-sided boundary window has a nonzero first coordinate <moment>, explaining the first-order bias. An invertible <local linear regression> fit reproduces $m(x)=x$ exactly at the target and removes this term. If $k=0$, the local constant average is undefined rather than zero, so a nonempty window is a necessary condition.