Solved – Selecting kernel bandwidth in practice

I am writing a blogpost on mapping in R, and a topic I incidentally touch on is optimal selection of bandwidth in kernel density estimation.

Below is a map of Charlotte (NC, USA), the colors indicate a kernel density estimate of crime. I am using a Gaussian kernel (which seems reasonable).

The question is which bandwidth to use.

Below bandwidth (0.01) looks reasonable:

"Just right" kernel bandwidth

This bandwidth (0.1) looks too large:

"Too big" kernel bandwidth

This bandwidth looks too small:

"too small kernel bandwidth"

I came up with the following rule of thumb for kernel bandwidth selection (bearing in mind that most readers may not be very technically inclined):

Pick an arbitrary bandwidth.

  • If it seems too low, multiply it by 3. If it still seems too low, multiply it by three again, and so on, until it becomes too high.

  • Conversely, if the bandwidth seems too high, divide it by three again and again until it seems too low.

Pick the diagram which best represents the picture you want to convey (you may wish to do further adjustment of the bandwidth before coming to your final choice, e.g. experiment by increasing and decreasing the chosen value a little).

Does anyone have a better suggestion?

The typical strategy in cases like this is to compute the Risk (aka mean squared error) and choose the bandwidth that minimizes it. In practice, Risk can be decomposed into the sum of the variance of the smoothed surface and the square of the bias (distance of the smoothed surface from the data surface). For small bandwidth, bias is low but variance is high. For large bandwidth, bias is high but variance is low. See, e.g., the locfit package in R. A good discussion (for the 1D case and for 2D regression) is in Larry Wasserman's All of Non-parametric Statistics.

Similar Posts:

Rate this post

Leave a Comment