Scripts, Batch-mode and
ClassicBUGS
The Scripting Language
As an alternative to the menu/dialog box interface of
WinBUGS
a scripting language has been provided. This language can be useful for automating routine analysis. The language works in effect by writing values into fields and clicking on buttons in relevant dialog boxes. Note that it is possible to combine use of this scripting language with use of the menu/dialog box interface.
To make use of the scripting language for a specific problem, a minimum of four files are required: the script itself; a file containing the BUGS language representation of the model; a file (or several) containing the data; and for each chain a file containing initial values. Each file may be in either native
WinBUGS
format (.odc) or text format, in which case it must have a .txt extension.
Below is a list of currently implemented commands in the scripting language. Alongside each is a brief synopsis of its menu/dialog box equivalent: first we have the menu name and then the associated menu option; then, an underlined name corresponds to a button in a dialog box, whereas a name without an underline corresponds to a dialog box field set equal to the value of the quantity in italics on the other side of the = sign.
If the menu/dialog box equivalent of the specified script command would normally be greyed out, because of inappropriate timing, for example, then the script command will not execute and an error message will be produced instead.
script command menu/dialog box equivalent
modelOutput(
option
) Options -> Display options... -> output =
option
where
option
= "window" or "log"
modelPrecison(prec)
Options -> Display option...
-> output precision = prec
modelQuit() File -> Exit
modelSaveLog(
file
)
1
File -> Save As... -> File name: =
file
+
Save
modelGetSeed() Model -> Seed... -> seed
modelSetSeed(newSeed) Model -> Seed... -> seed = newSeed +
set
modelCheck(
model file
) Model -> Specification... ->
check model
modelData(
data file
) Model -> Specification... ->
load data
modelCompile(numC
hains
) Model -> Specification... ->
num of chains =
chains
+
compile
modelInits(
inits file, chain
) Model -> Specification... ->
for chain =
chain
+
load inits
modelGenInits() Model -> Specification... ->
gen inits
modelUpdate(
iterations, thin
) Model -> Update... -> updates =
iterations
+
update
samplesSetBeg(
iter
) Inference -> Samples... -> beg =
iter
samplesSetEnd(
iter
) Inference -> Samples... -> end =
iter
samplesSetFirstChain(chain) Inference -> Samples... -> chains =
chain
samplesSetLastChain(chain) Inference -> Samples... -> to =
chain
samplesThin(
thin
) Inference -> Samples... -> thin =
thin
samplesSet(
node
) Inference -> Samples... -> node =
node
+
set
samplesClear(
node
) Inference -> Samples... -> node =
node
+
clear
samplesStats(
node
) Inference -> Samples... -> node =
node
+
stats
samplesDensity(
node
) Inference -> Samples... -> node =
node
+
density
samplesAutoC(
node
) Inference -> Samples... -> node =
node
+
auto cor
samplesTrace(
node
) Inference -> Samples... -> node =
node
+
trace
samplesHistory(
node
) Inference -> Samples... -> node =
node
+
history
samplesQuantiles(
node
) Inference -> Samples... -> node =
node
+
quantiles
samplesBgr(
node
) Inference -> Samples... -> node =
node
+
bgr diag
samplesCoda(
node
,
file stem
)
1
Inference -> Samples... -> node =
node
+
coda
summarySet(
node
) Inference -> Summary... -> node =
node
+
set
summaryStats(
node
) Inference -> Summary... -> node =
node
+
stats
summaryMean(
node
) Inference -> Summary... -> node =
node
+
mean
summaryClear(
node
) Inference -> Summary... -> node =
node
+
clear
rankSet(
node
) Inference -> Rank... -> node =
node
+
set
rankStats(
node
) Inference -> Rank... -> node =
node
+
stats
rankStats(
node
) Inference -> Rank... -> node =
node
+
histogram
rankClear(
node
) Inference -> Rank... -> node =
node
+
clear
dicSet() Inference -> DIC... ->
set
dicClear() Inference -> DIC... ->
clear
dicStats() Inference -> DIC... ->
stats
1
If the file ends with ".txt" the log window is saved to a text file (with all graphics, fonts, etc., stripped out); otherwise the log window is saved as is.
The mapping between
commands in the BUGS script language and the Component Pascal procedure to execute them is in the file Bugs/Rsrc/Script.txt. There is one special command "INIT()" that OpenBUGS uses to initialize its startup: this command is not for the user to execute.
Batch-mode
The shortcut
BackBUGS
has been set up to run the commands contained in the script file
script
(in the root directory of
WinBUGS
) when it is double-clicked. Thus a
WinBUGS
session may be embedded within any software component that can execute the
BackBUGS
shortcut.
ClassicBUGS
A version of BUGS called ClassicBUGS is a cut down version without any graphical user interface or the ability to produce graphics. It has a command line interaface which understands the commands in the BUGS scripting language that do not involve graphics. At present ClassicBUGS is the only version of OpenBUGS that runs on Linux.