Introduction
1. What is GAUSS?
GAUSS is a programming language designed to operate with and on matrices. It is a general purpose tool. As such, it is a long way from more specialised econometric packages. On a spectrum which runs from the computer language C at one end to, say, the menu-driven econometric program EViews at the other, GAUSS is very much at the programming end. Using GAUSS thus calls for a very different approach to other packages. Although a number of econometric add-ons have been written (for example, ML-GAUSS, a suite of maximum likelihood applications), you will rarely be able to "turn up and go" with GAUSS. More often than not, getting useful results from GAUSS requires thought, a systematic approach, and usually a little time. Having said that, the thought required is often no more than a recognition of what precisely you are trying to achieve. The GAUSS operators and the standard library functions are designed to work with matrices. This means that if you can write down the operations you want to perform, the chances are that they can be translated directly into a line in your program. The statement "β=(X'X)-1X'y" is acceptable to GAUSS with only minor changes.
1.1 Advantages
1.2 Disadvantages
1.3 When to use GAUSS
GAUSS is ideally suited to non-standard tasks. For example, we have developed programs to analyse and do estimates on data which comes in the form of cross-product matrices. Alternatively, you may wish to vary or add to standard techniques; for example, adding a new estimator. If the core of your task is matrix manipulation in any way, then GAUSS is likely to be a better bet than a full programming language. Its primitive I/O facilities are offset by the processing capability. However, GAUSS is not appropriate for, say, writing a menu system; a general-purpose language is probably easier. Nor is GAUSS appropriate for standard applications on standard datasets. There is little point in writing a probit estimation routine in GAUSS for a small dataset. Firstly, there are already routines commercially available for non-linear estimation using GAUSS. More importantly, TSP, LimDep, etc will already perform the estimation and there is no necessity to learn anything at all about GAUSS to use these programs. However, to get extra specification tests, for example, a straightforward solution would be to code a routine and emend the preexisting GAUSS probit program to call the new procedure at the appropriate point in its working. | ||||||||||||||||||
2. Platforms and interfaces
GAUSS is available in both single user versions and networked versions. From the user's perspective, the main difference is that you may have less control over your environment in a network setting, but otherwise the versions are the same. For the system administrator, the network version simplifies license and user management, particularly for shared machines.
2.1 GAUSS on a PC
GAUSS for PCs now comes as a Windows application. However, for those wanting to use the old DOS-based interface a program called TGAUSS.exe is included with the distribution. There appears to be a negligible speed difference between the two except for programs displaying a lot of information on the screen.
2.2 GAUSS on Unix/Linux
GAUSS on Unix is very powerful and very quick, partly because Unix machines are designed for heavy-duty processing and computation rather than user interaction. For manipulating large matrices, the time saving can be tremendous. GAUSS on Unix runs in both teletype (command-line) and X-Windows mode. Access to the latter depends on how you access your Unix machine. There is also a version to run on Linux (a form of Unix which runs on Intel processors). For simplicity, this guide will not distinguish bewtween Unix and Linux.
2.3 Memory management
In the early days of GAUSS, efficient memory management was often crucial to getting a program running well. The amount of memory used by GAUSS could be varied by the user to make appropriate use of scarce resources. However, this is much less of an issue in modern computers, and from version 4.0 for Windows, GAUSS no longer gives you the option to manage memory directly. Instead it relies on the more efficient memory-management facilities of the operating system. This does not mean you may ignore the issue of effective programming skills. It is suprisingly easy to run out of memory when doing complex operations on large matrices. For a more detailed discussion see the section on code refinements.
2.4 Interfaces
GAUSS programs can be written in two ways:
However, the practical differences between versions of GAUSS on various operating systems are minimal. The GAUSS code covered in this guide should be universally applicable. Thus there is no section of the guide concentrating on the interfaces. At the moment, I suggest you refer to the manual for your particular version. The forthcoming book An Introduction to GAUSS for economists includes short movies about using the Windows interfaces. | back to top | |||||||||||||||||
3. Notation and layout
GAUSS is not case-sensitive. However, throughout the guide capitals will be used for 'reserved words' and standard GAUSS functions. The names of all variables are lower case, with capital letters separating words. Procedures will be identified by an initial capital. All this makes no difference to GAUSS; it just makes life easier (see section on Writing for posterity). Italics will be used to indicate a value to be substituted. Where a constant is mentioned, this means an actual number or character set. Values are the results of some operation. Where a constant is required, a constant must be supplied; but where a value is required either a constant or a value is acceptable. Constant-list and value-list are lists of constants or values, separated by spaces or punctuation marks. The type of separator may affect the result of the operation.
3.1 Examples
Naming conventions
Constants
a "a" 27 "ok" -0.0062 5.3E+2
Invalid constants
a*b c-27
Constant-lists
a b c d e a, b, c, "a", "b", "c" 1,2,3,4.5,6.7,8 1 2 3 4.5 6.7 "hello" 8 values
a "a" a*b b+a "ok" 5.3*102 5.3E+2 -27*(63+5)
value-lists
a*b, b*c, c*a a*b 25 b*c "hello" c*a Note that, when constants are expected, a string constant (a piece of text) may or may not be enclosed in quotation marks. It makes no difference to GAUSS, other than to make errors more likely. By contrast, when a value is expected, a string without quotation marks will be treated as a variable the current value of which is to be used. To try to avoid this confusion, this coursebook will place string constants in quotation marks; strings with no quotation marks will be variables. For large numbers we use GAUSS's scientific notation standard; that is 5,720 can be written as 5.72E+3 (5.72 x 103) and 0.05 as 5.0E-2 (5.0 x 10-2).
3.2 Layout and Syntax
GAUSS could be described as a free-form structured language: structured because GAUSS is designed to be broken down into easily-read chunks; free-form because there is no particular layout for programs. Although the syntax is closely defined, extra spaces between words (including line breaks) are ignored. Commands are separated by a semi-colon, rather than having one command on each line as in FORTRAN or BASIC. A complete instruction is identified by the placing of semicolons, and not by the placing of commands on different lines. Program layout is generally a matter of supreme indifference to GAUSS, and this gives the user freedom to lay out code in a style he finds acceptable. For example, the conditional branching operation IF could be written
IF condition; action1; ELSE; action2; ENDIF;
but equally acceptable to GAUSS would be
The coursebook will use the leftmost of these formats, but this is a matter of personal choice and users may wish to develop their own style. More will be made of this in Writing for posterity. There are some exceptions to the rule that layout does not matter. Obviously, there cannot be extraneous spaces within words or numbers: 'I F', 'var 1' and '27 000' are not the same as 'IF', 'var1' and '27000'. In more recent versions of GAUSS spaces within mathematical expressions are not allowed in certain places, although this does not seem to be consistently enforced - for example, when entering expressions on the command line. The other place where spacing is important is in comments:
/* this is a comment */
Anything within the /*...*/ markers is ignored by the program. However, there must not be a space between the slash and the asterisk, or the program will not recognise a comment marker and will erroneously try to analyse the contents of the comment block. | back to top | |||||||||||||||||
4. Using GAUSS
GAUSS in common with many other programs, will take instructions either from a file or from the command line. To start GAUSS:
To exit GAUSS, either close the window or type "QUIT" or "SYSTEM". Command-line mode is fine for testing a few instructions, but for anything more than a couple of lines of code it is more sensible to operate in batch mode. In this case, you type the instructions into a separate text file, and then tell GAUSS to run the instructions in one go (a batch) with the command
RUN fileName
This will execute all the instructions in the file fileName in sequence. The results are, in theory, identical, whether the commands are in a file or typed in one at a time. The choice of when to work at the command line and when to place instructions in a file depends on the problem at hand; however, for more than a couple of lines of code, working in a file is usually easier. Specific instructions as to how to edit and save text files depend upon your operating system. In the rest of this guide "program" will refer to any self-contained body of code we are working on, and you will find it easier to write the programs in separate files. You can run programs directly without having to load GAUSS. At the Unix prompt, for example, entering
gauss fileName
will load GAUSS and run the program automatically. Under Windows, enter GAUSS or TGAUSS to load and run the Windows or non-Windows version. If you do not include either SYSTEM or QUIT and then end of our program then when the program has finished it will leave you in the GAUSS environment.
4.1 The help system: a warning GAUSS has two electronic help systems, corresponding to the manuals. The "Command Reference" is an easy way to pick up information on commands (as long as they are not deemed "obsolete"), and is organised both alphbetically and by function, which is useful. It is very terse and does not display properly, but generally seems accurate. The "User Guide" is slightly more chatty, and has more examples. Note however that it is less reliable. First, information on old commands is left unchanged, even though the commands may operate in a different way in later versions or has been deleted altogether. Second, information on new functions is often not forthcoming in that version. The first problem does seem to be disappearing, but if something doesn't work as the manual says it should, don't assume that it's your code that's wrong. |
Introduction
最新推荐文章于 2024-10-15 14:04:56 发布