MATA Programming

Stata Interface

Using MATA Built-In Functions

Controlling Execution Flow

Example 1

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?

Writing Your Own Functions

Object Code and Library

Example 2

Write a MATA function to convert one or more quarterly time series into the annual series by taking the average of every four data points.