Stata Press books

Maximum Likelihood Estimation with Stata, Fourth Edition

William Gould, Jeffrey Pitblado, and Brian Poi
Copyright 2010
ISBN-13: 978-1-59718-078-8
Pages: 352; paperback
Price $54.00
See the back cover
Table of contents
Preface (pdf)
Author index (pdf)
Subject index (pdf)
Errata
Download the datasets used in this book
Download the brochure (pdf)

Comment from the Stata technical group

Maximum Likelihood Estimation with Stata, Fourth Edition is the essential reference and guide for researchers in all disciplines who wish to write maximum likelihood (ML) estimators in Stata. Beyond providing comprehensive coverage of Stata’s ml command for writing ML estimators, the book presents an overview of the underpinnings of maximum likelihood and how to think about ML estimation.

The book shows you how to take full advantage of the ml command’s noteworthy features:

When appropriate options are used, many of these features are provided automatically by ml and require no special programming or intervention by the researcher writing the estimator.

The fourth edition has been updated to include new features introduced in recent versions of Stata. Such features include new methods for handling scores, more consistent arguments for likelihood-evaluator programs, and support for likelihood evaluators written in Mata (Stata’s matrix programming language). The authors illustrate how to write your estimation command so that it fully supports factor-variable notation and the svy prefix for estimation with survey data. They have also restructured the chapters that introduce ml in a way that allows you to begin working with ml faster. This edition is essential for anyone using Stata 11.

In the final chapter, the authors illustrate the major steps required to get from log-likelihood function to fully operational estimation command. This is done using several different models: logit and probit, linear regression, Weibull regression, the Cox proportional hazards model, random-effects regression, and seemingly unrelated regression.

The authors provide extensive advice for developing your own estimation commands. With a little care and the help of this book, users will be able to write their own estimation commands—commands that look and behave just like the official estimation commands in Stata.

Whether you want to fit a special ML estimator for your own research or wish to write a general-purpose ML estimator for others to use, you need this book.


Table of contents

List of tables
List of figures
Preface to the fourth edition (pdf)
Versions of Stata
Notation and typography
1 Theory and practice
1.1 The likelihood-maximization problem
1.2 Likelihood theory
1.2.1 All results are asymptotic
1.2.2 Likelihood-ratio tests and Wald tests
1.2.3 The outer product of gradients variance estimator
1.2.4 Robust variance estimates
1.3 The maximization problem
1.3.1 Numerical root finding
Newton’s method
The Newton–Raphson algorithm
1.3.2 Quasi-Newton methods
The BHHH algorithm
The DFP and BFGS algorithms
1.3.3 Numerical maximization
1.3.4 Numerical derivatives
1.3.5 Numerical second derivatives
1.4 Monitoring convergence
2 Introduction to ml
2.1 The probit model
2.2 Normal linear regression
2.3 Robust standard errors
2.4 Weighted estimation
2.5 Other features of method-gf0 evaluators
2.6 Limitations
3 Overview of ml
3.1 The terminology of ml
3.2 Equations in ml
3.3 Likelihood-evaluator methods
3.4 Tools for the ml programmer
3.5 Common ml options
3.5.1 Subsamples
3.5.2 Weights
3.5.3 OPG estimates of variance
3.5.4 Robust estimates of variance
3.5.5 Survey data
3.5.6 Constraints
3.5.7 Choosing among the optimization algorithms
3.6 Maximizing your own likelihood functions
4 Method lf
4.1 The linear-form restrictions
4.2 Examples
4.2.1 The probit model
4.2.2 Normal linear regression
4.2.3 The Weibull model
4.3 The importance of generating temporary variables as doubles
4.4 Problems you can safely ignore
4.5 Nonlinear specifications
4.6 The advantages of lf in terms of execution speed
5 Methods lf0, lf1, and lf2
5.1 Comparing these methods
5.2 Outline of evaluators of methods lf0, lf1, and lf2
5.2.1 The todo argument
5.2.2 The b argument
Using mleval to obtain values from each equation
5.2.3 The lnfj argument
5.2.4 Arguments for scores
5.2.5 The H argument
Using mlmatsum to define H
5.2.6 Aside: Stata’s scalars
5.3 Summary of methods lf0, lf1, and lf2
5.3.1 Method lf0
5.3.2 Method lf1
5.3.3 Method lf2
5.4 Examples
5.4.1 The probit model
5.4.2 Normal linear regression
5.4.3 The Weibull model
6 Methods d0, d1, and d2
6.1 Comparing these methods
6.2 Outline of method d0, d1, and d2 evaluators
6.2.1 The todo argument
6.2.2 The b argument
6.2.3 The lnf argument
Using lnf to indicate that the likelihood cannot be calculated
Using mlsum to define lnf
6.2.4 The g argument
Using mlvecsum to define g
6.2.5 The H argument
6.3 Summary of methods d0, d1, and d2
6.3.1 Method d0
6.3.2 Method d1
6.3.3 Method d2
6.4 Panel-data likelihoods
6.4.1 Calculating lnf
6.4.2 Calculating g
6.4.3 Calculating H
Using mlmatbysum to help define H
6.5 Other models that do not meet the linear-form restrictions
7 Debugging likelihood evaluators
7.1 ml check
7.2 Using the debug methods
7.2.1 First derivatives
7.2.2 Second derivatives
7.3 ml trace
8 Setting initial values
8.1 ml search
8.2 ml plot
8.3 ml init
9 Interactive maximization
9.1 The iteration log
9.2 Pressing the Break key
9.3 Maximizing difficult likelihood functions
10 Final results
10.1 Graphing convergence
10.2 Redisplaying output
11 Mata-based likelihood evaluators
11.1 Introductory examples
11.1.1 The probit model
11.1.2 The Weibull model
11.2 Evaluator function prototypes
Method-lf evaluators
lf-family evaluators
d-family evaluators
11.3 Utilities
Dependent variables
Obtaining model parameters
Summing individual or group-level log likelihoods
Calculating the gradient vector
Calculating the Hessian
11.4 Random-effects linear regression
11.4.1 Calculating lnf
11.4.2 Calculating g
11.4.3 Calculating H
11.4.4 Results at last
12 Writing do-files to maximize likelihoods
12.1 The structure of a do-file
12.2 Putting the do-file into production
13 Writing ado-files to maximize likelihoods
13.1 Writing estimation commands
13.2 The standard estimation-command outline
13.3 Outline for estimation commands using ml
13.4 Using ml in noninteractive mode
13.5 Advice
13.5.1 Syntax
13.5.2 Estimation subsample
13.5.3 Parsing with help from mlopts
13.5.4 Weights
13.5.5 Constant-only model
13.5.6 Initial values
13.5.7 Saving results in e()
13.5.8 Displaying ancillary parameters
13.5.9 Exponentiated coefficients
13.5.10 Offsetting linear equations
13.5.11 Program properties
14 Writing ado-files for survey data analysis
14.1 Program properties
14.2 Writing your own predict command
15 Other examples
15.1 The logit model
15.2 The probit model
15.3 Normal linear regression
15.4 The Weibull model
15.5 The Cox proportional hazards model
15.6 The random-effects regression model
15.7 The seemingly unrelated regression model
A Syntax of ml
B Likelihood-evaluator checklists
B.1 Method lf
B.2 Method d0
B.3 Method d1
B.4 Method d2
B.5 Method lf0
B.6 Method lf1
B.7 Method lf2
C Listing of estimation commands
C.1 The logit model
C.2 The probit model
C.3 The normal model
C.4 The Weibull model
C.5 The Cox proportional hazards model
C.6 The random-effects regression model
C.7 The seemingly unrelated regression model
References
Author index (pdf)
Subject index (pdf)