The Inference Menu
Contents
General properties
Samples...
Compare...
Correlations...
Summary...
Rank...
DIC...
General properties [top]
These menu items open dialog boxes for making inferences about parameters of the model. The commands are divided into three sections: the first three commands concern an entire set of monitored values for a variable; the next two commands are space-saving short-cuts that monitor running statistics; and the final command, DIC..., concerns evaluation of the Deviance Information Criterion proposed by Spiegelhalter et al . (2002) . Users should ensure their simulation has converged before using Summary..., Rank... or DIC... Note that if the MCMC simulation has an adaptive phase it will not be possible to make inference using values sampled before the end of this phase.
Samples... [top]
This command opens a non-modal dialog for analysing stored samples of variables produced by the MCMC simulation. The fields are:
node: The variable of interest must be typed in this text field. If the variable of interest is an array, slices of the array can be selected using the notation variable[lower0:upper0, lower1:upper1, ...]. The buttons at the bottom of the dialog act on this variable. A star '*' can be entered in the node text field as shorthand for all the stored samples.
WinBUGS generally automatically sets up a logical node to measure a quantity known as deviance ; this may be accessed, in the same way as any other variable of interest, by typing its name, i.e. "deviance", in the node field of the Sample Monitor Tool . The definition of deviance is -2 * log(likelihood): 'likelihood' is defined as p( y | theta ), where y comprises all stochastic nodes given values (i.e. data), and theta comprises the stochastic parents of y - 'stochastic parents' are the stochastic nodes upon which the distribution of y depends, when collapsing over all logical relationships.
beg and end: numerical fields are used to select a subset of the stored sample for analysis.
thin: numerical field used to select every k th iteration of each chain to contribute to the statistics being calculated, where k is the value of the field. Note the difference between this and the thinning facility on the Update Tool dialog box: when thinning via the Update Tool we are permanently discarding samples as the MCMC simulation runs, whereas here we have already generated (and stored) a suitable number of (posterior) samples and may wish to discard some of them only temporarily. Thus, setting k > 1 here will not have any impact on the storage (memory) requirements of processing long runs; if you wish to reduce the number of samples actually stored (to free-up memory) you should thin via the Update Tool .
chains . to .: can be used to select the chains which contribute to the statistics being calculated.
clear: removes the stored values of the variable from computer memory.
set: must be used to start recording a chain of values for the variable.
trace: plots the variable value against iteration number. This trace is dynamic, being redrawn each time the screen is redrawn.
history: plots out a complete trace for the variable.
The next six buttons will be greyed out if the MCMC simulation is in an adaptive phase.
density: plots a smoothed kernel density estimate for the variable if it is continuous or a histogram if it is discrete.
auto cor: plots the autocorrelation function of the variable out to lag-50. The values underlying these can be listed to a window by double-clicking on the plot followed by ctrl -left-mouse-click: if multiple chains are being simulated the values for each chain will be given.
stats: produces summary statistics for the variable, pooling over the chains selected. The required percentiles can be selected using the percentile selection box. The quantity reported in the MC error column gives an estimate of s / N 1/2 , the Monte Carlo standard error of the mean. The batch means method outlined by Roberts (1996; p.50) is used to estimate s.
coda: dumps out an ascii representation of the monitored values suitable for use in the CODA S-Plus diagnostic package. An output file for each chain is produced, corresponding to the .out files of CODA , showing the iteration number and value (to four significant figures). There is also a file containing a description of which lines of the .out file correspond to which variable - this corresponds to the CODA .ind file. These can be named accordingly and saved as text files for further use. (Care may be required to stop the Windows system adding a .txt extension when saving: enclosing the required file name in quotes should prevent this.)
quantiles: plots out the running mean with running 95% confidence intervals against iteration number.
bgr diag: calculates the Gelman-Rubin convergence statistic, as modified by Brooks and Gelman (1998). The width of the central 80% interval of the pooled runs is green, the average width of the 80% intervals within the individual runs is blue, and their ratio R (= pooled / within) is red - for plotting purposes the pooled and within interval widths are normalised to have an overall maximum of one. The statistics are calculated in bins of length 50: R would generally be expected to be greater than 1 if the starting values are suitably over-dispersed. Brooks and Gelman (1998) emphasise that one should be concerned both with convergence of R to 1, and with convergence of both the pooled and within interval widths to stability.
The values underlying these plots can be listed to a window by double-clicking on the plot followed by ctrl -left-mouse-click on the window.
See WinBUGS Graphics for details of how to customize these plots.
Compare... [top]
Select Compare... from the Inference menu to open the Comparison Tool dialog box. This is designed to facilitate comparison of elements of a vector of nodes (with respect to their posterior distributions).
node: defines the vector of nodes to be compared with each other. As the comparisons are with respect to posterior distributions, node must be a monitored variable.
other: where appropriate, other defines a vector of reference points to be plotted alongside each element of node (on the same scale), for example, other may be the observed data in a model fit plot (see below). The elements of other may be either monitored variables, in which case the posterior mean is plotted, or they may be observed/known.
axis: where appropriate, axis defines a set of values against which the elements of node (and other ) should be plotted. Each element of axis must be either known/observed or, alternatively, a monitored variable, in which case the posterior mean is used.
Note: node , other , and axis should all have the same number of elements!
beg and end: are used to select the subset of stored samples from which the desired plot should be derived.
box plot: this command button produces a single plot in which the posterior distributions of all elements of node are summarised side by side. For example,
By default, the distributions are plotted in order of the corresponding variable's index in node and are also labelled with that index. Boxes represent inter-quartile ranges and the solid black line at the (approximate) centre of each box is the mean; the arms of each box extend to cover the central 95 per cent of the distribution - their ends correspond, therefore, to the 2.5% and 97.5% quantiles. (Note that this representation differs somewhat from the traditional.)
(The default value of the baseline shown on the plot is the global mean of the posterior means.)
There is a special "property editor" available for box plots, as indeed there is for all graphics generated via the Comparison Tool . This can be used to interact with the plot and change the way in which it is displayed, for example, it is possible to rank the distributions by their means or medians and/or plot them on a logarithmic scale. For full details, please see Box plot .
caterpillar: a "caterpillar" plot is conceptually very similar to a box plot. The only significant differences are that the inter-quartile ranges are not shown and the default scale axis is now the x-axis - each distribution is summarised by a horizontal line representing the 95% interval and a dot to show where the mean is. (Again, the default baseline - in red - is the global mean of the posterior means.) Due to their greater simplicity caterpillar plots are typically preferred over box plots when the number of distributions to be compared is large. See Caterpillar plot for details of how to change the properties of caterpillar plots.
model fit: the elements of node (and other if specified) are treated as a time-series, defined by (increasing values of) the elements of axis . The posterior distribution of each element of node is summarised by the 2.5%, 50% and 97.5% quantiles. Each of these quantities is joined to its direct neighbours (as defined by axis ) by straight lines (solid red in the case of the median and dashed blue for the 95% posterior interval) to form a piecewise linear curve - the 'model fit'. In cases where other is specified, its values are also plotted, using black dots, against the corresponding values of axis , e.g.
Where appropriate, either or both axes can be changed to a logarithmic scale via a property editor - see Model fit plot .
scatterplot: by default, the posterior means of node are plotted (using blue dots) against the corresponding values of axis and an exponentially weighted smoother is fitted. Numerous properties of a scatterplot can be modified using the editor described in Scatterplot - for example, the smoothing parameter may be changed, or the smoother may be replaced by a different type of line, or 95% posterior intervals for node may be displayed, etc.
Correlations... [top]
This non-modal dialog box is used to plot out the relationship between the simulated values of selected variables, which must have been monitored.
nodes : scalars or arrays may be entered in each box, and all combinations of variables entered in the two boxes are selected. If a single array is given, all pairwise correlations will be plotted.
scatter: produces a scatter plot of the individual simulated values.
matrix: produces a matrix summary of the cross-correlations.
print : opens a new window containing the coefficients for all possible correlations among the selected variables.
The calculations may take some time.
Summary.. . [top]
This non modal dialog box is used to calculate running means, standard deviations and quantiles. Th e commands in this dialog are less powerful and general than those in the Sample Monitor Too l, but they also require much less storage (an important consideration when many variables and/or long runs are of interest).
node: The variable of interest must be typed in this text field.
set : starts recording the running totals for nod e.
stats : displays the running means, standard deviations, and 2.5%, 50% (median) and 97.5% quantiles for nod e. Note that these running quantiles are calculated via an approximate algorithm (se e her e for details) and should therefore be used with caution .
means : displays the running means for nod e in a comma delimited form. This can be useful for passing the results to other statistical or display packages.
clear: removes the running totals for nod e.
Rank.. . [top]
This non-modal dialog box is used to store and display the ranks of the simulated values in an array.
node : the variable to be ranked must be typed in this text field (must be an array).
set : starts building running histograms to represent the rank of each component of nod e. An amount of storage proportional to the square of the number of components of nod e is allocated. Even when nod e has thousands of components this can require less storage than calculating the ranks explicitly in the model specification and storing their samples, and it is also much quicker.
stats : summarises the distribution of the ranks of each component of the variable nod e. The quantiles highlighted in the percentile selection box are displayed.
histogram : displays the empirical distribution of the simulated rank of each component of the variable nod e.
clear : removes the running histograms for nod e.
DIC.. . [top]
The DIC Too l dialog box is used to evaluate the Deviance Information Criterio n (DIC; Spiegelhalter et a l., 200 2 ) and related statistics - these can be used to assess model complexity and compare different models. Most of the example s packaged with WinBUG S contain an example of their usage.
It is important to note that DIC assumes the posterior mean to be a good estimate of the stochastic parameters. If this is not so, say because of extreme skewness or even bimodality, then DIC may not be appropriate. There are also circumstances, such as with mixture models, in which WinBUGS will not permit the calculation of DIC and so the menu option is greyed out. Please see the WinBUGS 1.4 web-page for current restrictions:
http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/contents.shtml
set : starts calculating DIC and related statistics - the user should ensure that convergence has been achieved before pressing se t as all subsequent iterations will be used in the calculation.
clear : if a DIC calculation has been started (via se t) this will clear it from memory, so that it may be restarted later.
DIC : displays the calculated statistics, as described below; please see Spiegelhalter et a l. (2002 ) for full details; the section Tricks: Advanced Use of the BUGS Languag e also contains some comments on the use of DIC.
The DIC button generates the following statistics:
Dbar : this is the posterior mean of the deviance, which is exactly the same as if the node 'deviance' had been monitored (see here ). This deviance is defined as -2 * log(likelihood): 'likelihood' is defined as p(y | thet a), where y comprises all stochastic nodes given values (i.e. data), and thet a comprises the stochastic parent s of y - 'stochastic parents' are the stochastic nodes upon which the distribution of y depends, when collapsing over all logical relationships.
Dhat : this is a point estimate of the deviance (-2 * log(likelihood)) obtained by substituting in the posterior means theta.ba r of thet a: thus Dhat = -2 * log(p(y | theta.ba r)) .
pD : this is 'the effective number of parameters', and is given by pD = Dbar - Dha t. Thus pD is the posterior mean of the deviance minus the deviance of the posterior means.
DIC : this is the 'Deviance Information Criterion', and is given by DIC = Dbar + pD = Dhat + 2 * p D. The model with the smallest DIC is estimated to be the model that would best predict a replicate dataset of the same structure as that currently observed .