Although full functionality is available via the Graphical User Interface (GUI), oftentimes it may become cumbersome and time consuming to submit commands via this route. For example, it happens very often in practice that one needs to add one extra independent variable to a model previously estimated, leaving all other model parameters unchanged. In such a case, including the additional variable in the model can be done by a few keystrokes rather than a series of mouse clicks. Furthermore, creating and deleting variables or otherwise transforming data may involve repetitive tasks that can be accomplished much faster through writing code, rather than via the menu.
To address these issues, BayES features a programming language that allows making adjustments to previously submitted commands and data processing much more eﬃcient. That said, someone ﬂuent in the BayES language can dispense of the graphical environment altogether and work only using code.
The BayES language is very intuitive and users of software packages that work with matrices or arrays will ﬁnd the transition to programming in BayES’ language very easy. Furthermore, to facilitate use of the language, every time a command is submitted through the GUI, the ﬁrst thing that is printed on the BayES console is the code that accomplishes the tasks requested by the user.1
The easiest way to write and submit code for execution to BayES is by invoking the script editor from the menu: View → Script Editor.2 The window that pops up is a simple text editor designed to highlight code that is written in the BayES language. There are three equivalent ways of submitting code for execution via the graphical user interface:
via the script editor’s menu: Run → Run
by clicking the Run button on the script editor’s toolbar (below the window’s menu)
by hitting the Ctrl/Cmd and R keys simultaneously (Ctrl+R)
Any of these procedures will submit for interpretation and execution all the contents of the active script tab in the editor window. Alternatively, if you wish to submit only part of the code in a script ﬁle, highlight the part of the code you want to execute before submitting it, using any of the three ways mentioned above. Script ﬁles can be saved on the computer’s hard disk, typically using a .bsf (BayES script ﬁle) extension.
BayES can also be invoked from the command line without starting up the graphical environment.3 In this context, BayES can execute the commands contained in a script ﬁle and either print output on the system console or redirect output to another text ﬁle.
BayES ships with a number of sample ﬁles. During installation these ﬁles are extracted in a folder named Samples under the BayES installation directory. These ﬁles contain sample code that is typically much more complete than the examples found in this guide. They contain many comments and are self-explanatory. To run the sample code open them from the script editor window and click on the Run button or hit Ctrl+R.
Note that many of these ﬁles contain statements like setwd("$BayESHOME");. This statement sets the working directory to the BayES installation directory, so that it can call functions and load data from ﬁles that are located in the folders created during installation.
1In fact, the only role for the GUI in BayES is to prepare code based on user input. Once a command is submitted via the GUI (typically by clicking on an “OK" or “RUN" button), the associated code is printed on the console and then interpreted, performing the requested task.