BayES BayES

2.1 Introduction

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 efficient. That said, someone fluent 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 find 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 first thing that is printed on the BayES console is the code that accomplishes the tasks requested by the user.1

2.1.1 Writing and submitting code

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:

  1. via the script editor’s menu: Run Run

  2. by clicking the Run button on the script editor’s toolbar (below the window’s menu)

  3. 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 file, highlight the part of the code you want to execute before submitting it, using any of the three ways mentioned above. Script files can be saved on the computer’s hard disk, typically using a .bsf (BayES script file) 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 file and either print output on the system console or redirect output to another text file.

2.1.2 Using the sample files that come with BayES

BayES ships with a number of sample files. During installation these files are extracted in a folder named Samples under the BayES installation directory. These files 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 files 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 files 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.

2See also the video tutorial “Working with Code: The BayES Script Editor".

3See section 1.2.2 and the video tutorial “Working with BayES from the Command Shell".

Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis