Creating and Editing a GAUSS Program
Example: Lesson 2.1
File I/O and Data Transformation
Example: Lesson 2.2
Example: Lesson 2.3
GAUSS Built-In Functions
Example: Lesson 2.4
- Data Generating Functions:
ones, zeros, eye, seqa, seqm, rndu, rndn
- Data Conversion Functions:
reshape, selif, delif, vec, vech, xpnd, submat, diag, diagrv
- Basic Matrix Functions:
- Matrix Description:
rows, cols, maxc, minc, meanc, median, stdc
- Matrix Operations:
sumc, cumsumc, prodc, cumprodc, sortc, sorthc, sortind
- Matrix Computation:
det, inv, invpd, solpd, vcx, corrx, cond, rank, eig,eigh
- Probability and Statistical Functions:
pdfn, cdfn, cdftc, cdffc, cdfchic, dstat, ols
- Calculus Functions:
gradp, hessp, intsimp, linsolve, eqsolve, sqpsolve
Controlling Execution Flow
- If Statement
if; then; else; elseif; endif;
- For Loop
for i (start,stop,step); ... endfor;
- Do Loop
do while ... endo;
do until ... endo;
Example:
Do you know the accuracy of your computer's numerical calculation?
This example addresses this important problem.
Suppose e is a known small positive number, and the 5x4 matrix X is
defined as follows:
1 1 1 1
e 0 0 0
0 e 0 0
0 0 e 0
0 0 0 e
Verify that the eigenvalues of X'X are 4+e2, e2, e2, and e2.
How small of the value of e your computer will allow so that X'X can be inverted?
(Program).
Writing Your Own Functions
- Single Line Function
fn fn_name(args) = code_for_function;
- Procedure
proc [[(nrets)=]] proc_name(arg_list);
local list of local variables;
... statements in the body of procedure;
retp(ret_list);
endp;
Example:
Write a single-line GAUSS function to convert a quarterly time series into the annual
series by taking the average of every four data points. How you extend the single-line
version of time series conversion function to a multi-line procedure so that it can handle
the conversion of more than one time series?
(Program).
Library and Package
- Publication Quality Graphics (PQG) Library
- Commercial Packages: CML, CO, FANPAC, etc.
Example:
Using GAUSS to present and solve the following functions:
- f(x) = ln(x) - x2
Hint: The maximal of f(x) is found at x = Ö½ or 0.707.
(Program).
- g(x) = (x12 + x2 - 11)2 +
(x1 + x22 -7)2
Hint: There are four minima: (3, 2), (3.5844, -1.8481), (-3.7793, -3.2832), (-2.8051, 3.1313).
(Program).