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:

This bandwidth (0.1) looks too large:

This bandwidth looks too small:

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?

**Contents**hide

#### Best Answer

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:

- Solved – Kernel density estimation -Effect of bandwidth
- Solved – How to compute Integrated Squared Error for kernel density estimation in R
- Solved – How to compute Integrated Squared Error for kernel density estimation in R
- Solved – How to decide whether a Kernel Density Estimate is good
- Solved – How to decide whether a Kernel Density Estimate is good