[scripts0]    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.

The scripting language is the same as the command line interface used in the ClassicBUGS flavour of OpenBUGS, with the exception that ClassicBUGS does not have any commands to produce graphic output. The script language is also very similar to the R interface to OpenBUGS called BRugs.

The translation between commands in the script language and the underlying Component Pascal procedures is in the file Bugs/Mod/Script.odc. There are two versions of each script command, the first for use with the graphical user interface and the second for use with ClassicBUGS (the second version can be empty). Commands marked with an asterixs produce graphics output and do not work in ClassicBUGS, or do not work with ClassicBUGS for some other reason.

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
OpenBUGS 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 (in bold) then the associated menu option or dialog box; then possibly a button in the dialog box, or the name of a dialog box field set equal to the value of the quantity on the other side of the equals sign. Script commands can take two types of arguments: strings and integers. If a string argument contains non-alpha-numeric characters (including space but excluding the period) the string must be enclosed in double quotes. If an argument is in italics it must be supplied by the user, other arguments will be set to default values if absent.

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
   
   modelCheck( string )    Model (Specification... )   
   modelData(
string )    Model (Specification... )   
   modelEnableDynamic()   
Model (Specification... )   dynamic compilation = TRUE
   modelDisableDynamic()   
Model (Specification... )   dynamic compilation = FALSE
   modelCompile(
int )    Model (Specification...)   
         num of chains = int
   modelInits(
string , int)    Model (Specification...)   
         for chain = chain
   modelGenInits()   
Model (Specification...)   

   _____________________________________________________________________
   
   modelUpdate( int0 , int1, string)    Model (Update...)   
         updates = int0,
         thin = int1
         over relax = string
   _____________________________________________________________________

   modelSaveState(string)   
Model (Save State)   fileStem = string
   _____________________________________________________________________

   modelGetRN(int)   
Model (RN generator...)   seed
   modelSetRN(int0,
int1 )    Model (RN generator...)   
         seed = int1
         state = int0
   _______________________________________________________________

      
   modelOutput(
string )    Model (Inout/Output options...)
         Input options = window / log
    modelPrecison( int )    Model (Inout/Output options...)
         output precision = int
   _____________________________________________________________________

   modelDisable(
string )    Model (Updater options...)   disable = TRUE
         methods = string
   modelEnable(
string )    Model (Updater options...)   enable = TRUE
         methods = string
   modelSetAP(
string , int )    Model (Updater option...)   adaptive phase = int
         methods = string
   modelSetIts(string,
int )    Model (Updater option...)   iterations = int
         methods = string
   modelSetOR(string,
int )    Model (Updater option...)   over-relaxation = int
         methods = string
   _____________________________________________________________________         
   modelExternalize(
string )    Model (Externalize)   File name: = string
   
   modelInternalise(
string )    Model (Internalize)   File name: = string
   

   modelQuit()    File (Exit)
   modelSaveLog(
string ) 1     File (Save As...)   
         File name: = string

   _____________________________________________________________________
   
   samplesBeg(
int )    Inference (Samples...)   beg = int
   samplesEnd(
int )    Inference (Samples... )   end = int
   samplesFirstChain(
int )    Inference (Samples...)   chains = int
   samplesLastChain(
int )    Inference (Samples... )   to = int
   samplesThin( int )    Inference (Samples...)   thin = int
   samplesSet(
string )    Inference (Samples...)   
         node = string
   samplesClear(
string )    Inference (Samples...)   
         node = string
   samplesStats(
string )    Inference (Samples...)   
         node = string
   *samplesDensity(
string )    Inference (Samples...)   
         node = string
   *samplesAutoC(
string )    Inference (Samples...)   
         node = string
   *samplesTrace(
string )    Inference (Samples...)   
         node = string
   *samplesHistory(
string )    Inference (Samples...)   
         node = string
   *samplesQuantiles(
string )    Inference (Samples...)   
         node = string
   *samplesBgr(
string )    Inference (Samples...)   
         node = string
   samplesCoda(
string0 , string1)    Inference (Samples...)   
         node = string0
         fileStem = string1

   ______________________________________________________________
   
   summarySet( string )    Inference (Summary...)   
         node = string
   summaryStats(
string )    Inference (Summary...)   
         node = string
   summaryMean(
string )    Inference (Summary...)   
         node = string
   summaryClear(
string )    Inference (Summary... )   
         node = string
   _____________________________________________________________________
         

   rankSet( string )    Inference (Rank... )   
         node = string

   
rankStats( string )    Inference (Rank... )   
         node = string
   *rankHistrogram(
string )    Inference (Rank...)   
         node = string
   rankClear(
string )    Inference (Rank...)   
         node = string

   _____________________________________________________________________
   
   dicSet()    Inference (DIC...)   
   dicClear()   
Inference (DIC... )   
   dicStats()   
Inference (DIC... )   
   _____________________________________________________________________
   
   infoNodeValues(
string )    Info (Node info...)   
         node = string
   infoNodeMethods(
string )    Info (Node info...)   
         node = string
   infoNodeTypes(
string )    Info (Node info...)   
         node = string
   _____________________________________________________________________
   
   
*infoUnitializedUpdaters()    Info (Uninitialized Nodes)
    infoUpdatersbyName()    Info (Updaters(by name))
    infoUpdatersbyDepth()    Info (Updaters(by depth))
   _____________________________________________________________________
   
   infoModules()   
Info (Modules)
   
   
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.

Batch-mode

The shortcut
BackBUGS has been set up to run the commands contained in the script file script (in the root directory of OpenBUGS ) when it is double-clicked. Thus a OpenBUGS session may be embedded within any software component that can execute the BackBUGS shortcut.