Using the gretl Language

The gretl GUI is certainly easy to use. However, you can get results even faster by using gretl’s language. The language can be used from the console or by collecting several lines of programming code into a file and executing them all at once in a script. Gretl now has a name for its scripting language, hansl. Hansl is a recursive acronym for hansl’s a neat scripting language (or handy scripting language), and it is certainly that. There are many things you can do using this powerful tool. Hansl’s syntax is particularly easy to use, in my opinion, and I strongly recommend that you learn to use it.

An important fact to keep in mind when using gretl is that its language is case sensitive. This means that lower case and capital letters have different meanings in gretl. The practical implication of this is that you need to be very careful when using the language. Since gretl considers x to be different from X, it is easy to make programming errors. If gretl gives you a programming error statement that you can’t quite decipher, make sure that the variable or command you are using is in the proper case.

1.3.1 Console

Gretl’s console provides you a way to execute programs interactively. A console window opens and from the prompt (?) you can execute gretl commands one line at a time. You can open the gretl console from the Tools pull-down menu or by a left mouse click on the “Gretl console” button on the toolbar. This button is the third one on the left side of the toolbar in Figure 1.3. From the console you execute commands, one by one by typing gretl code after the command prompt. Each command that you type in is held in memory so that you can accumulate what amounts to a “command history.” To reuse a command, simply use the up arrow key to scroll through the commands you’ve typed in until you get to the one you want. You can edit the command to fix any syntax errors or to make any changes you desire before hitting the enter key to execute the statement.

From the command prompt, ‘?’ you can type in commands from the gretl language. For instance, to estimate the food expenditure model in section 2.4 using least squares type

? ols y const x

The results will be output to the console window. You can use the window’s scroll bar on the right hand side to scroll up if you need to.

Remember, (almost) anything that can be done with the pull-down menus can also be done through the console. Of course, using the console requires you to use the correct language syntax, which can be found in the gretl command reference. The command reference can be accessed from the toolbar by clicking the button that looks like a lifesaver. It’s the fourth one from the right hand side of the toolbar.


Figure 1.7: The toolbar appears at the bottom of the main menu.

The Command Reference is also accessible from the menu bar through Help. The option marked plain text F1 actually brings up all of the commands in a hypertext format. Clicking on anything in blue will take you to the desired information for that command. Obviously, the keyboard shortcut F1 will also bring up the command reference (Figure 1.8). You’ll also notice

that. pdf versions of the Command and Function references can also be retrieved from the Help drop-down menu.


Figure 1.8: The command reference can be accessed in a number of ways: The ‘life-saver’ icon on the toolbar, Help>Command reference from the pull-down menu, or keyboard shortcut F1.

Notice that you can also search for commands by topic from the command syntax window. On the left side is a panel headed as Index (see Figure 1.9). Choose the desired category from the list and then select the command you want help with (e. g., Estimation>arch). The words indicated in blue text are links to related commands. For instance, clicking on garch will take you to the reference entry for garch modeling.

The function reference is a relatively new addition to gretl that will help you to locate the names gretl uses to temporarily store results (called accessors), to transform variables, and to write your own programs. To access the function reference, click Help>Function reference from the pull-down menu as shown in Figure 1.10.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>