next up previous contents index
Next: References Up: CODA Convergence Diagnosis and Previous: Exiting from CODA and

Using CODA with Gibbs sampling output from other programs

 

CODA is not restricted only for use with BUGS output, but may be applied to the output from any Gibbs sampler. The user must simply ensure that such output is stored in the same format   as the BUGS output files. The following 2 files illustrate the requirements:

Output file: myfile.out

     1  3.095403
     2  5.342834
     3  2.985434
     4  3.839403
     5  4.899420
     1  10.324302
     2  13.234031
     3  12.094324
     4   9.093849
     5  12.849322
     1  -0.034222
     2  -0.069030
     3  -0.049302
     4  -0.093243
     5  -0.044034

Index file: myfile.ind

     alpha       1    5
     beta[1]     6   10
     beta[2]    11   15

That is, the samples should be saved in a space delimited rectangular ASCII file with filename extension `.out'. Column 1 represents iteration number and column 2 contains the sampled values for each parameter, stored `end-to-end'. A second ASCII file with extension `.ind' should contain the index associated with the `.out' file. This consists of 3 columns giving the variable names, and line numbers corresponding to the first and last values for each variable in the `.out' file.

Alternatively, CODA can read Gibbs sampler output which is stored directly as an S-Plus object   (to input this data format, select option 2: `Begin a new CODA session using data saved from a previous CODA session' after invoking CODA -- see §2.3.2). The S-Plus object must be a list, each element of which represents a separate run of the Gibbs sampler. Optional names may be assigned to each element in the list; otherwise, CODA will automatically assign the names ` chain_1', ` chain_2',... etc. Each element itself consists of a matrix where column 1 (which MUST be named `iter') contains the iteration number, and subsequent columns (which MUST be given variable names) contain the sampled values for each variable of interest. The following example illustrates the required S-Plus format for 2 parallel runs of the Gibbs sampler:

> my.S.file
[[1]]:
     iter    alpha   beta[1]   beta[2]
[1,]    1 3.095403 10.324302 -0.034222
[2,]    2 5.342834 13.234031 -0.069030
[3,]    3 2.985434 12.094324 -0.049302
[4,]    4 3.839403  9.093849 -0.093243
[5,]    5 4.899420 12.849322 -0.044034

[[2]]:
     iter    alpha   beta[1]   beta[2]
[1,]    1 2.437995  8.303402 -0.065222
[2,]    2 4.710123 11.033923 -0.067843
[3,]    3 5.762293 12.218843 -0.059523
[4,]    4 5.513237  7.221548 -0.079514
[5,]    5 3.660194  8.263983 -0.039586



Daniel Farewell
Tue Sep 14 16:08:04 BST 1999