This page announced updates in Stata 10. See a complete overview of all of
Stata's matrix programming features.
|
Order
|
Mata
For an introduction to Mata, click here.
Here’s what’s new in Stata 10
-
New Stata command
include is a variation on
do and
run
and is useful for implementing #include for
header files in advanced programming situations. See [P]
include and type
viewsource optimize.mata for an example of use.
-
Mata now has structures, which will be of special interest to those
writing large systems. See [M-2]
struct and [M-5]
liststruct().
-
Mata now engages in more thorough type checking, and produces better code,
for those who explicitly declare arguments and variables.
-
Mata inherits all of Stata’s formats and functions for dealing
with the new date/time variables and values; see [M-5]
date() and [M-5]
fmtwidth().
-
New functions inbase() and
frombase perform base conversions; see [M-5]
inbase().
-
New function floatround() returns values rounded
to float precision. This is Mata’s equivalent of Stata’s
float()
function. See [M-5]
floatround().
-
New function nameexternal() returns the name of
an external; see [M-5]
findexternal().
-
Concerning matrix manipulation,
-
Matrix multiplication is now faster when one of the matrices contains
many zeros, as is function
cross().
-
Appending rows or columns to a matrix using , and \
is now faster.
-
New function _diag() replaces the principal
diagonal of a matrix with a specified vector or scalar; see [M-5]
_diag().
-
New functions select() and
st_select() select rows or columns of a
matrix on the basis of a criterion; see [M-5]
select().
-
Existing functions
rowsum(),
colsum(),
sum(),
quadrowsum(),
quadcolsum(), and
quadsum()
now allow an optional second argument that determines how missing
values are handled; see [M-5]
sum().
-
New functions
runningsum(),
quadrunningsum(),
_runningsum(), and
_quadrunningsum()
return the running sum of a vector; see [M-5]
runningsum().
-
New functions minindex() and
maxindex() return the indices of minimums
and maximums (including tied values) of a vector; see [M-5]
minindex().
-
Concerning statistics,
-
New Mata function optimize() performs
minimization and maximization. You can code just the function, the
function and its first derivatives, or the function and its first and
second derivatives. Optimization techniques include
Newton–Raphson, Davidon–Fletcher–Powell,
Broyden–Fletcher–Goldfarb–Shanno,
Berndt–Hall–Hall–Hausman, and the simplex method
Nelder–Mead. See [M-5]
optimize().
-
New function cvpermute() forms permutations;
see [M-5]
cvpermute().
-
New function ghk() provides the
Geweke–Hajivassiliou–Keane multivariate normal
simulator; see [M-5]
ghk().
New function ghkfast() is faster but a
little more difficult to use; see [M-5]
ghkfast().
-
New functions halton(),
_halton(), and ghalton() compute
Halton and Hammersley sets; see [M-5]
halton().
-
The new density and probability functions available in Stata are also
available in Mata, including
binomial(),
binomialtail(),
gammaptail(),
invgammaptail(),
invbinomialtail(),
ibetatail(),
invibetatail(),
lnnormal(), and
lnnormalden();
see [M-5]
normal().
Also, as in Stata, convergence and accuracy of many of the
cumulatives, reverse cumulatives, and density functions have been
improved.
-
Existing Mata functions
mean(),
variance(),
quadvariance(),
meanvariance(),
quadmeanvariance(),
correlation(), and
quadcorrelation()
now make the weight argument optional.
If not specified, unweighted estimates are returned. See
[M-5] mean().
-
Concerning string processing,
-
New function stritrim() replaces multiple,
consecutive internal spaces with one space; see [M-5]
strtrim().
-
New functions strtoreal() and
_strtoreal() convert strings to numeric
values; see [M-5]
strtoreal().
-
New function _substr() substitutes a
substring into an existing string; see [M-5]
_substr().
-
New function invtokens() is the inverse of
the existing function tokens(); see [M-5]
invtokens().
-
New function tokenget() performs advanced
parsing; see [M-5]
tokenget().
-
Concerning I/O,
-
New function adosubdir() returns the subdirectory in
which Stata would search for a file; see [M-5]
adosubdir().
New function
pathsearchlist(fn)
returns a row vector of full paths/filenames specifying all the
locations, in order, where Stata would look for the specified
fn along the official Stata ado-path; see [M-5]
pathjoin().
-
New function byteorder() returns 1 if the
computer is HILO and returns 2 if the computer is LOHI; see [M-5]
byteorder().
-
New undocumented function st_fopen()
makes opening files easier; see
help mata
st_fopen().
-
New functions bufput() and
bufget() copy elements into and out of
buffers; see [M-5]
bufio().
-
Existing function cat() now allows optional
second and third arguments that specify the beginning and ending lines
of the file to read; see [M-5]
cat().
-
New functions ferrortext() and
freturncode() obtain error messages and return
codes following an I/O error; see [M-5]
ferrortext().
-
Concerning the Stata interface,
-
New function stataversion() returns the version of Stata
that you are running, and new function statasetversion()
allows setting it. See [M-5]
stataversion().
-
New function setmore() allows turning
more on and off. New function
setmoreonexit() allows restoring
more to its original setting when execution
ends. See [M-5]
more().
-
New undocumented function st_lchar() allows
storing exceedingly long strings (such as a varlist) in Stata dataset
characteristics. See
help mata
st_lchar().
Back to highlights