1
$\begingroup$

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?

$\endgroup$
4
  • 2
    $\begingroup$ Bandwidth selection is really a statistical issue rather than a programming specific problem. I believe your question belongs on Cross Validated where statistical topics are discussed. $\endgroup$ – MrFlick Jun 13 '15 at 2:49
  • $\begingroup$ Many people work with the idea that you bracket a "good" bandwidth with a larger one that evidently smooths too much and a smaller one that doesn't remove enough noise. But it is important to remember that a bandwidth is not just a number but here, if I understand what you are doing correctly, a number with distance units. So, there should be substantive knowledge that should help with this: What is the spatial resolution of the data? Are they really point data or data for lots of small areas? Also, on what scales do you expect to see patterns? Is there no subject-matter expertise to guide? $\endgroup$ – Nick Cox Jun 13 '15 at 9:17
  • $\begingroup$ Thanks! I've updated my blog post based on your comment. It really helps. $\endgroup$ – wwl Jun 13 '15 at 11:51
  • $\begingroup$ If you wanna go for something simple use a plug in value, for instance Silverman's rule of thumb. Also the choice of kernel doesn't really matter for practically any "real" application, however choosing the right bandwidth is infinitely important. There are fully data driven ways to do this, but I think they are far beyond the scope of your (neat) blog entry. $\endgroup$ – Repmat Jul 8 '16 at 20:56
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.