[logo]
The BUGS Project
The BUGS Project
version 0.5 manual


next previous contents
Next: 8 Errors Previous: 6 Running BUGS

7 Processing output

7.1 Main output

If you have been following the worked line example, examine file bugs.out,   which contains output in the form shown below.

501         3.07739     
502         3.21921     
503         2.38693     
       ......
1499        4.76044E-1  
1500        3.19312E-1

The first column represents the iteration number (501 - 1500) and the second column is the sampled values. To relate each such value to a variable one refers to the bugs.ind   whose contents are reproduced below.

alpha               1              1000           
beta                1001           2000           
sigma               2001           3000           
tau                 3001           4000

This specifies that lines 1 to 1000 of bugs.out correspond to variable alpha, lines 1001 to 2000 are values for beta, and so on.

The suite of S-plus functions, CODA, distributed with BUGS provide plots, summary statistics and convergence diagnostics. See the CODA manual for details.

7.2 Output of summary statistics

The stats command also writes the output to a file called by default bugs1.out   in a rectangular format suitable for reading into statistical packages for producing graphs, tables and so on. The 10 columns contain the following summary statistics: (1) mean, (2) standard deviation, (3) lower percentile being reported (default 2.5%), (4) observed lower percentile, (5) upper percentile being reported (default 97.5%), (6) observed upper percentile, (7) median, (8) number of iterations, (9) start iteration, (10) finish iteration.

For the line example the results are as follows and should be compared with the results of using the stats command shown in Section 6.

 3.017E+0   6.851E-1   2.500E+0   1.996E+0   9.750E+1   4.111E+0   3.012E+0  1000  501   1500  
 7.811E-1   4.002E-1   2.500E+0  -8.670E-2   9.750E+1   1.528E+0   7.993E-1  1000  501   1500  
 1.041E+0   8.770E-1   2.500E+0   4.305E-1   9.750E+1   2.837E+0   8.265E-1  1000  501   1500  
 1.836E+0   1.439E+0   2.500E+0   1.239E-1   9.750E+1   5.391E+0   1.463E+0  1000  501   1500

The file bugs1.ind contains the node names for the variables listed, and the corresponding row number in the bugs1.out file.

alpha 1
beta 2
sigma 3
tau 4

Repeated output from stats commands will simply be appended to the end of these files during a single run (note that use of the out command will overwrite this output).  

7.3 Convergence: using the diag command

We have deliberately not dwelt on the problems of assessing convergence, which is covered in the CODA manual. Broadly we follow the philosophy of Gelman and Rubin (1992) that a number of long runs should be carried out from widely differing starting points and statistical analysis carried out using the components of variance of the multiple sequences.   By using multiple initial data files it is possible to carry out such a procedure using BUGS, and this will be illustrated in future versions.

While recommending several long runs from over-dispersed starting points, for single runs we do include two commands, diag and out, which may help in the monitoring process.

diag calculates a simple test statistic intended to indicate whether an early part of a run differs substantially from the later part, and is a rough approximation to that suggested by Geweke (1992).   A selected set of sampled values is divided into two segments: the first quarter (early) and the second half (late) . The saved values in each segment are divided into 25 bins and the mean of each bin is calculated, denoted tex2html_wrap_inline3177 and tex2html_wrap_inline3179 . The empirical means and variances of these two sets of 25 numbers are calculated to be tex2html_wrap_inline3181 , and the standardised test statistic

displaymath3183

is expected to have a standard normal distribution if the sample is all from the same distribution. We note that auto-correlation between the tex2html_wrap_inline3185 's may tend to make the empirical variances too low and hence the procedure anti-conservative, in suggesting differences between early and late data that are too extreme. The command allows an arbitrary set of monitored values to be selected, and prints out tex2html_wrap_inline3187 and Z.

7.4 Convergence: using the out command

The command out sends, at any time in a run, the saved values of a monitored node to a file (default bugs1.out)   with index information going to a separate file (default bugs1.ind).   The user is then able to calculate any specific monitoring statistic at any time. We note that this will overwrite any results of stats that have been sent to file, and similarly the results of out will be overwritten by subsequent use of stats. If both commands are required, some judicious renaming of files will be required during the run.

For the line example the results of a comand out(beta) will be as follows. In bugs1.out will be stored the sampled values

501         7.31789E-1  
502         8.65938E-1  
503         1.14477     
504         1.23844     
505         5.97648E-1  
    ........
1498        4.73403E-1  
1499        1.02701     
1500        1.49829E-1

while the file bugs1.ind contains the labels for the variables listed.

beta                1              1000

This is in a format ready to be read into CODA for analysis.



next previous contents
Next: 8 Errors Previous: 6 Running BUGS

Comments to bugs@mrc-bsu.cam.ac.uk
© 1995 MRC Biostatistics Unit
Return to the Welcome Page