Which is the formula from Silverman to calculate the bandwidth in a kernel density estimation? I want to calculate a better bandwidh for my kernel density estimator, which is an Epanechnikov. I use Silverman's formula which involves the standard deviation of the sample, the sample size and a constant, but I'm getting a very smooth curve in most cases and I would prefer if it were more balanced. Thank you for any help you can give me.
 A: I asked a similar question a few months ago. Rob Hyndman provided an excellent answer that recommends the Sheather-Jones method.
One addition point. In R, for the density function, you set the bandwidth explicitly via the bw argument. However, I often find that the adjust argument is more helpful. The adjust argument scales the value of the bandwidth. So adjust=2 means double the bandwidth.
A: I second @onestop, but quote Wilcox, 'Introduction to Robust Estimation and Hypothesis Testing', 2nd edition, page 50:
$$
h = 1.06\frac{A}{n^{1/5}}, \qquad A = \min{\left(s,\frac{IQR(x)}{1.34}\right)},
$$
where $s$ is the sample standard deviation.
A: To shamelessly quote the Stata manual entry for kdensity:

The optimal width is the width that would minimize the mean integrated squared error if the data were Gaussian and a Gaussian kernel were used, so it is not optimal in any global sense. In fact, for multimodal and highly skewed densities, this width is usually too wide and oversmooths the density (Silverman 1992).

Silverman, B. W. 1992. Density Estimation for Statistics and Data Analysis. London: Chapman & Hall. ISBN 9780412246203
The formula Stata give for the optimal bandwidth $h$ is:
$$h = \frac{0.9m}{n^{1/5}} \quad \mbox{with } m = \min\left(\sqrt{\operatorname{Var}(X)},\frac{\operatorname{IQR}(X)}{1.349}\right),$$
where $n$ is the number of observations on $X$, $\operatorname{Var}(X)$ is its variance and $\operatorname{IQR}(X)$ its interquartile range.
A: What I usually do is to calculate the plugin bandwidth using Silverman's formula (h_p) and then crossvalidate in the range of [h_p/5, 5h_p] to find the optimal bandwidth. This crossvalidation can be done either by using leave-one-out least squares crossvalidation or by leave-one-out-likelihood crossvalidation.
