For each target value x0 of a risk factor, the subjects get tri-cube weights Ki from a nearest-neighbour window, and a logistic model with logit β0 + β1(x − x0) is fitted by maximising the weighted log-likelihood ∑ Ki [yiηi − log(1 + eηi)]; the fitted prevalence at x0 is 1/(1 + e−β̂0). Dropping the slope gives the local constant fit, which is just the kernel-weighted proportion of cases. Move x0 to see the local model that produces each point of the curve, on the probability scale (top) and on the logit scale (bottom).
The band is η̂(x) ± one standard error mapped to the probability scale; the standard error is the sandwich A−1BA−1 of the weighted likelihood. The kernel density classifier uses Gaussian kernels with Silverman's bandwidth in each class and the class proportions as priors. Ticks at the top are cases (CHD), at the bottom controls.
code/ch06_kernel_smoothing.py (local_logistic, kde_classifier, logistic_fit, fig_6_12); the fitted values here are those of the Python functions.