Department of Biomedical Engineering and Computational Science

Using Classic BUGS and WinBUGS with Matlab

Two helper functions and some examples of using Classic BUGS and WinBUGS with Matlab.

Helper functions

Last updated 2003-08-19

Save Matlab variables in S-PLUS format for BUGS
Read BUGS CODA output to Matlab structure
These were originally written by Jouko Lampinen and modified by Aki Vehtari.

Thanks for Leming Qu sending a fix for mat2bugs.m and Windows Matlab. mat2bugs.m used fprintf('%G',val) which worked just fine, but for some reason Windows Matlab prints 3 digits in exponent while WinBUGS 1.4 requires that there is only 2 digits...


Related software

MATBUGS is a Matlab interface for WinBugs written by Kevin Murphy, Maryam Mahdaviani and Alfred Pang. Matbugs differs from mat2bugs in that it automatically generates the script file, calls WinBUGS, reads in the results (using bugs2mat), and then performs simple convergence diagnostics. Thus it provides complete functionality, just like R2WinBugs, rather than merely converting file formats.