|
Project Information
|
MATBUGS: a matlab interface to WinBUGSMATBUGS is a Matlab interface for WinBugs and OpenBugs, which are programs for Gibbs sampling applied to hierarchical Bayesian models. Written by Kevin Murphy and Maryam Mahdaviani, August 2005. Changelog Download matbugs.m is the main file. This file, and several demos, are included in matbugs-7oct10.zip. Usage Here is a basic example of how to use matbugs: [samples, stats] = matbugs(dataStruct, modelFileName, ...
'init', initStructs, ...
'view', 1, 'nburnin', 1000, 'nsamples', 500, ...
'thin', 10, ...
'monitorParams', {'theta', 'mu_theta', 'sigma_theta'}, ...
'Bugdir', 'C:/Program Files/WinBUGS14');You can see that optional arguments are passed in the form 'name', value. To use openbugs, pass in the arguments 'openbugs', 1 . It is very important that you initialise the variables (using initStructs) to sensible values - if BUGS samples nodes from a vague prior, they will likely be extreme, and the program will crash! There are two outputs. |samples| is a structure, containing one field per variable that you have chosen to monitor e.g. samples.theta(c,s) is the value of sample s in chain c. For vectors, use samples.theta(c,s,i) and for matrices, samples.theta(c,s,i,j). |stats| is a structure containing the mean, variance and EPSR statistic computed over samples for each monitored variable. Demos The examples below give more details on how to use the program User contributions If you want to contribute changes to the code, demos or documentation, send an email to Kevin Murphy and I can give you write access to the svn repository. How it works Matbugs automatically generates the script file from the model (e.g., see this example script file), calls WinBUGS, reads in the results (using bugs2mat), and then performs simple convergence diagnostics. Thus it provides complete functionality, very similar to R2WinBUGS and bugsR. Issues on MS Windows systems If you are using Windows 7 or Windows Vista, make sure you install winbugs in a directory to which you have write permission - don't use 'C:\Program Files\Winbugs14'. I use 'C:\kmurphy\Programs\Winbugs14' and then modify the 'Bugdir' argument when calling matbugs. |