The size of bandwidth chosen for kernel density estimation determines the degree of smoothing produced. It is often useful to examine several density plots of the same samples, all smoothed by different amounts, in order to gain greater insight into the data. Selecting option 7 of the CODA Plotting Defaults Menu displays the following list of functions which available in CODA for calculating the bandwidth of the kernel density estimator:
Select kernel bandwidth function required: 1: Default: Smooth (0.25 * sample range) 2: Coarse (Silverman 1986 eqn. 3.28 & 3.30) 3: User-defined function 4: Return to Plotting Defaults Menu Selection:
Option 1 is the default, and produces a smooth density estimate but one which may hide local features of the posterior.
The bandwidth function recommended by silverman:86 (equations 3.28 and 3.30 on pp. 45 and 47) is
where bw is the bandwidth to be calculated, y are the sampled values, iqr(y) is the inter-quartile range of y, and n is the length of y. This bandwidth generally produces a less smooth, but possibly more accurate density estimate than does the CODA default, and may be implemented by selecting option 2 of the bandwidth menu.
Selecting the third option from this menu enables the user to specify his or her own bandwidth function. This must be entered as a function of y, and must be written in the S-Plus language. For example, to enter the function
type:
0.9 * sqrt(var(y)) * length(y)
( -1/5)
after the prompt. Alternatively, a single numeric value (such as 0.5 or 3.2) may be entered after the prompt if a fixed-value bandwidth is required. An error check is carried out to ensure that the function entered is readable by S-Plus and will return a single numeric value; if not the user is prompted to re-type it.