3.6 Interface to Stata®

Stata is a proprietary software package designed for data analysis, data management, and graphics. Stata provides canned procedures for estimating many popular econometric models, most of them being frequentist. However, recent versions of Stata also include Bayesian procedures. Stata has a complete GUI but it also features a simple scripting language, which makes running it in batch mode feasible.

BayESstata() function provides a convenient interface to Stata, which allows the user to:

The general syntax of the stata() function is the following:6

[<structure name> = ] stata( <Stata .do file> 
        [, "data"=<list of matrices/dataset to pass to Stata> ] 
        [, "return"=<list of matrices to retrieve from Stata> ] 


When the stata() function calls Stata, Stata starts only part of its GUI and executes the code contained in the provided Stata .do file. BayES automatically directs any Stata output to a log file. When execution of the code contained in the .do file completes BayES reads the Stata output and prints it on the BayES console. Therefore, BayES may appear frozen during the time Stata executes the commands in the .do file. The output printed on the BayES console is entirely determined by Stata and the commands contained in the Stata .do file provided to stata().

The sample script file in "$BayESHOME/Samples/5Interfaces/stata" contains an example of using the stata() function, along with a simple Stata .do file. The Stata interface is also accessible from the BayES main menu via Interfaces Stata®.

6Arguments inside square brackets are optional. Optional arguments passed to the stata() function can be provided in any order, but always after the mandatory argument (Stata .do file). Optional arguments always come in pairs (eg. "data"={myDataset,myMatrix}).

7Stata can handle only a single dataset at a time. If the user attempts to pass more than one datasets as data to Stata, stata() will issue an error.

8If you do not want the Stata dataset to be returned to BayES, simply include clear as the last line of code in the provided Stata .do file.

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