5th Edition

# Maximum Likelihood Estimation with Stata, Fifth Edition

472 Pages
by Stata Press

Maximum Likelihood Estimation with Stata, Fifth 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 commands for writing ML estimators, the book presents an overview of the underpinnings of maximum likelihood and how to think about ML estimation.

The fifth edition includes a new second chapter that demonstrates the easy-to-use mlexp command. This command allows you to directly specify a likelihood function and perform estimation without any programming.

The core of the book focuses on Stata's ml command. It shows you how to take full advantage of ml’s noteworthy features:

• Linear constraints
• Four optimization algorithms (Newton–Raphson, DFP, BFGS, and BHHH)
• Observed information matrix (OIM) variance estimator
• Outer product of gradients (OPG) variance estimator
• Huber/White/sandwich robust variance estimator
• Cluster–robust variance estimator
• Complete and automatic support for survey data analysis
• Direct support of evaluator functions written in Mata

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.

In later chapters, you will learn how to take advantage of Mata, Stata's matrix programming language. For ease of programming and potential speed improvements, you can write your likelihood-evaluator program in Mata and continue to use ml to control the maximization process. A new chapter in the fifth edition shows how you can use the moptimize() suite of Mata functions if you want to implement your maximum likelihood estimator entirely within Mata.

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. This edition adds a new example of a bivariate Poisson model, a model that is not available otherwise in Stata.

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.

Theory and practice

The likelihood-maximization problem

Likelihood theory

The maximization problem

Estimation with mlexp

Syntax

Normal linear regression

Initial values

Restricted parameters

Robust standard errors

The probit model

Specifying derivatives

Wrapping up

Introduction to ml

The probit mode

Normal linear regression

Robust standard errors

Weighted estimation

Other features of method-gf0 evaluators

Limitations

Overview of ml

The terminology of ml

Equations in ml

Likelihood-evaluator methods

Tools for the ml programmer

Common ml options

Maximizing your own likelihood functions

Appendix: More about scalar parameters

Method lf

The linear-form restrictions

Examples

The importance of generating temporary variables as doubles

Problems you can safely ignore

Nonlinear specifications

The advantages of lf in terms of execution speed

Methods lf0, lf1, and lf2

Comparing these methods

Outline of evaluators of methods lf0, lf1, and lf2

Summary of methods lf0, lf1, and lf2

Examples

Methods d0, d1, and d2

Comparing these methods

Outline of method d0, d1, and d2 evaluators

Summary of methods d0, d1, and d2

Panel-data likelihoods

Other models that do not meet the linear-form restrictions

Debugging likelihood evaluators

ml check

Using the debug methods

ml trace

Setting initial values

ml search

ml plot

ml init

Interactive maximization

The iteration log

Pressing the Break key

Maximizing difficult likelihood functions

Final results

Graphing convergence

Redisplaying output

Writing do-files to maximize likelihoods

The structure of a do-file

Putting the do-file into production

Writing ado-files to maximize likelihoods

Writing estimation commands

The standard estimation-command outline

Outline for estimation commands using ml

Using ml in noninteractive mode

Writing ado-files for survey data analysis

Program properties

Writing your own predict command

Mata-based likelihood evaluators

Introductory examples

Evaluator function prototypes

Utilities

Random-effects linear regression

Mata’s moptimize() function

Introductory examples

Restricting the estimation sample

Estimation preliminaries

Estimation

Results

Estimation commands

Regression redux

Other examples

The logit model

The probit model

Normal linear regression

The Weibull model

The Cox proportional hazards model

The random-effects regression model

The seemingly unrelated regression model

A bivariate Poisson regression model

Epilogue

Syntax of mlexp

Syntax of ml

Syntax of moptimize()

Likelihood-evaluator checklists

Method lf

Method d0

Method d1

Method d2

Method lf0

Method lf1

Method lf2

Listing of estimation commands

The logit model

The probit model

The normal model

The Weibull model

The Cox proportional hazards model

The random-effects regression model

The seemingly unrelated regression model

A bivariate Poisson regression model

References

### Biography

Jeff Pitblado is Executive Director, Statistical Software at StataCorp. Pitblado has played a leading role in the development of ml: he added the ability of ml to work with survey data, and he wrote the current implementation of ml in Mata.

Brian Poi previously worked as a developer at StataCorp and wrote many popular econometric estimators in Stata. Since then, he has applied his knowledge of econometrics and statistical programming in several areas, including macroeconomic forecasting, credit analytics, and bank stress testing.

William Gould is President Emeritus of StataCorp and headed the development of Stata for over 30 years. Gould is also the architect of Mata.