>> Home >> Products >> Features >> Matrix programming
Order Stata

Matrix programming—Mata


  • Interactive—type matrix expressions and see results
  • Development—full development environment for developing programs and commands
  • Automatically compiled code

General features and matrix operators

  • Matrices with more than 2 billion rows and columns in Stata/MP New
  • Matrices with up to 2 billion rows and columns in Stata/SE and Stata/IC
  • Support for real and complex values
  • Joining by rows or columns
  • Addition, subtraction, multiplication, and scalar division
  • Elementwise arithmetic
  • Transposition and reshaping
  • Kronecker and Hadamard products
  • Inner and outer products


  • Code the function, function and gradient, or function, gradient, and
  • Newton–Raphson, BFGS, DFP, BHHH, Nelder–Mead, and Gauss–Newton techniques
  • Versions for general problems and statistical problems like maximum likelihood
  • Covariance matrix based on Hessian, outer product of gradients, or robust/sandwich

Mathematical and matrix functions

  • LAPACK numerical analysis routines
  • Hundreds of mathematical, string, and matrix utility functions Updated
  • Unicode-aware string functions New
  • Locale-based sorting and string comparison New
  • Symmetric, nonsymmetric, and generalized inverses
  • Cholesky , LU , QR , and SVD solvers
  • Trigonometric and other transcendental functions
  • Gamma and factorial functions
  • Density and distribution functions Updated
  • Polynomial evaluation , arithmetic, and calculus
  • Hilbert , Toeplitz , and Vandermonde matrices
  • Duplication , commutation , and elimination matrices
  • Random-number generation Updated
  • Fast Fourier analysis
  • Cubic splines
  • Means , sums , minimums and maximums of matrices
  • Numerical first and second derivatives
Explore all of Mata’s functions.

Stata interface

  • Convert Stata datasets to matrices and vice versa
  • Virtual matrix views onto dataset
  • Access and set estimation-class and other macros
  • Manipulate dataset value labels

Compiled language

  • C/C++-like syntax
  • Classes
  • Structures
  • Pointers
  • Numeric and string types
  • Matrices as an intrinsic type, including row and column vectors and full matrices

Object-oriented programming

  • Inheritance
  • Virtual functions
  • Encapsulation of data structures and programs


  • Eigenvalues and eigenvectors
  • Cholesky
  • LU and LUD
  • QR
  • Schur
  • Hessenberg
  • Singular value
  • Permutation matrices

Data accumulation

  • Cross products
  • Cross products of deviations from means
  • Weighted and GLS-type cross products
  • Support for quad-precision cross products

Nonlinear system solver

  • Fixed-point and root-finding problems
  • Gauss–Seidel, Broyden–Powell, and Newton–Raphson methods

Creation of Word, Excel, and PDF files

  • Programmatic access to create Word documents
  • Low-level cell-by-cell access to write results to and read data from Excel, including graphs, formulas, date formats, currency formats, bold, italics, and more. Updated
  • Programmatic access to create PDF files New

Other features

  • String scalars and matrices, including Unicode support
  • File I/O , including buffered I/O
  • C-like syntax
  • Fast execution

Additional resource

Read the Introduction to Mata.

See New in Stata 14 for more about what was added in Stata 14.

The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ Watch us on YouTube