|
Version 2.0 (September 2015)
RunWinBUGSScript
The running of WinBUGS Scripts made easier
Why use RunWinBUGSScript
The following points are advantages to running your WinBUGS script yourself, that is, by typing the usual WinBUGS command at the DOS-prompt (not accounting for the advantage of not having to type a command at the DOS-prompt!)
Getting node statistics for exp() or inv.logit() for some nodes
As discussed on the WriteWinBUGSScript page, directly monitoring nodes such as
odds.ratio <- exp(log.OR)
in WinBUGS models can be problematic and lead to trap error messages. The -exp command in WriteWinBUGSScript will add a comment to the script generated, as in display(log) check('c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/models/SomeModel.txt') compile(1) gen.inits() update(1000) set(log.OR) update(1000) stats(*) density(log.OR) history(log.OR) save('c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/log/tmp.odc') save('c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/log/tmp-WinBUGSlog.txt') quit() # when done, compute stats for exp() of log.OR Of course, running this script directly from the DOS-prompt would not give any information about the exponentiated node at all, as it is a comment and hence is ignored. Running the same script with RunWinBUGSScript, however, will produce a WinBUGS text log file that includes node statistics about the exponentiated node, as in: Node statistics node mean sd MC error 2.5% median 97.5% start sample log.OR 0.02654 0.9779 0.02926 -1.973 0.01147 1.981 1001 1000 /odds ratio/ exp(log.OR) -> -> -> 0.1390 1.0115 7.2499 1001 1000 Dropping variables from data files
RunWinBUGSScript will read comments about deleting variables; for example, see the bottom two lines of the WinBUGS script excerpted below check('c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/models/model.txt') data('c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/data/list.txt') data('c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/data/rectangle.txt') # RunWinBUGSScript will drop the following variable(s) from file(s) above: # datavar1 datavar2These two lines were generated by WriteWinBUGSScript (see Dropping variables from data files section): RunWinBUGSScript will interpret them and make temporary copies of the modified data files, which will be used in place of the original data files in the modified WinBUGS script actually run. Consequently, the WinBUGS .odc output file may include unexpected paths to data files, as in check(c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/models/SomeModel.txt) model is syntactically correct data(c:/DOCUME~1/patrick/LOCALS~1/Temp/_rwbs.txt) data loaded data(c:/DOCUME~1/patrick/LOCALS~1/Temp/_rwbs1.txt)Don't worry! These files are the modified versions of data files listed in the original WinBUGS script submitted. The WinBUGS text log file is more informative about the true data files read with that regards as they list the original data files, followed by a comment relative to variables deletion. check(c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/models/SomeModel.txt) model is syntactically correct data(c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/data/list.txt) # from which the following variables was dropped: # datavar2 data loaded data(c:/users/pbelisle/My Documents/Home/MyProject/WinBUGS/data/rectangle.txt) # from which the following variable was dropped: # datavar1 How to use RunWinBUGSScript
RunWinBUGSScript is a program written in Perl. Please refer to my generic page on running Perl programs for instructions. Additional tip
From the instructions section linked above, you know that the natural way to submit a script to RunWinBUGSScript is to drag-and-drop the text file in which the script was filed onto RunWinBUGSScript's desktop icon. After running such a script and viewing the WinBUGS log file produced (whose name ends by -WinBUGSlog.txt), one may want to resubmit the script, after some modification to the model, the inits files, or even the data files. The natural way to resubmit the script is, again, to drag-and-drop it onto RunWinBUGSScript's desktop icon: however, since the user just had a look at the WinBUGS log file, it may be more convenient to just drag-and-drop that WinBUGS log file onto RunWinBUGSScript's desktop icon, rather than having to browse through Windows Explorer to find the script that produced it. Avoiding trap errors from permission settings on Windows 7 and Windows Vista platforms
Download RunWinBUGSScript
RunWinBUGSScript is a free program. Download version 2.0, unzip and make sure RunWinBUGSScript finds WinBUGS by changing the path to WinBUGS14.exe: edit the file RunWinBUGSScript.pl and change the path found on the line # our %My = (WinBUGS=> {path => "C:/Program Files (x86)/WinBUGS14/WinBUGS14.exe"});and uncomment that line (by removing the leading sharp character (#)). Be careful! Use forward slashes (/) rather than backslashes (\) in the path expression. |