List of tables

List of figures

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