Mata is a full-blown programming language that compiles what you type into bytecode, optimizes it, and executes it fast. Behind the scenes, many of Stata’s commands are implemented using Mata. You can use Mata to implement big systems, or you can use it interactively. Read about all of Mata's features.
To enter Mata, type mata at Stata’s dot prompt. To exit, type end at Mata’s colon prompt:
|mata (type end to exit)|
Mata supports real and complex numbers, binary and text strings (up to 2,147,483,647 characters long), and, for serious programming problems, even pointers!
Mata uses LAPACK routines for its advanced matrix features, such as Cholesky decomposition, LU decomposition, QR decomposition, SV decomposition, eigenvalues and eigenvectors, and solvers and inverters.
Mata supports matrices that are views onto, not copies of, the data. Say you have loaded a dataset of 200,000 observations and 150 variables, and you need a matrix of 80 of those variables in 180,000 of the observations. Rather than requiring 110 megabytes, Mata needs only 640 bytes.
Matrix languages evaluate matrix expressions, such as b=invsym(X'X)*X'y, and Mata is no exception. Because of Mata’s design, however, it is fast enough to work at the element level. Here is Mata’s polynomial solver:
Much of Mata is written in Mata.