Stata 15 help for mlexp

[R] mlexp -- Maximum likelihood estimation of user-specified expressions

Syntax

mlexp (lexp) [if] [in] [weight] [, options]

where lexp is a substitutable expression representing the log-likelihood function.

options Description ------------------------------------------------------------------------- Model variables(varlist) specify variables in model from(initial_values) specify initial values for parameters constraints(numlist) apply specified linear constraints collinear keep collinear variables

Derivatives derivative(/name = dexp) specify derivative of lexp with respect to parameter name; can be specified more than once

SE/Robust vce(vcetype) vcetype may be oim, opg, robust, cluster clustvar, bootstrap, or jackknife Reporting level(#) set confidence level; default is level(95) title(string) display string as title above the table of parameter estimates title2(string) display string as subtitle display_options control columns and column formats, row spacing, line width, display of omitted variables and base and empty cells, and factor-variable labeling

Maximization maximize_options control the maximization process; seldom used

debug display debug output coeflegend display legend instead of statistics ------------------------------------------------------------------------- lexp and dexp may contain factor variables and time-series operators; see fvvarlist and tsvarlist. bootstrap, by, jackknife, rolling, statsby, and svy are allowed; see prefix. Weights are not allowed with the bootstrap prefix. aweights are not allowed with the jackknife prefix. vce() and weights are not allowed with the svy prefix. aweights, fweights, iweights, and pweights are allowed; see weight. debug and coeflegend do not appear in the dialog box. See [R] mlexp postestimation for features available after estimation.

lexp and dexp are substitutable expressions, Stata expressions that also contain parameters to be estimated. The parameters are enclosed in curly braces and must satisfy the naming requirements for variables; {beta} is an example of a parameter. The notation {lc:varlist} is allowed for linear combinations of multiple covariates and their parameters. For example, {xb: mpg price turn _cons} defines a linear combination of the variables mpg, price, turn, and _cons (the constant term). See Substitutable expressions under Remarks and examples of [R] mlexp.

Menu

Statistics > Other > Maximum likelihood estimation of expression

Description

mlexp performs maximum likelihood estimation of models that satisfy the linear-form restrictions, that is, models for which you can write the log likelihood for an individual observation and for which the overall log likelihood is the sum of the individual observations' log likelihoods.

You express the observation-level log-likelihood function by using a substitutable expression. Unlike models fit using ml, you do not need to do any programming. However, ml can fit classes of models that cannot be fit by mlexp.

Options

+-------+ ----+ Model +------------------------------------------------------------ variables(varlist) specifies the variables in the model. mlexp excludes observations for which any of these variables has missing values. If you do not specify variables(), then mlexp assumes all observations are valid. mlexp will exit with an error message if the log likelihood cannot be calculated at the initial values for any observation.

from(initial_values) specifies the initial values to begin the estimation. You can specify parameter names and values, or you can specify a 1 x k matrix, where k is the number of parameters in the model. For example, to initialize alpha to 1.23 and delta to 4.57, you would type

mlexp ..., from(alpha=1.23 delta=4.57) ...

or equivalently

matrix define initval = (1.23, 4.57) mlexp ..., from(initval) ...

Initial values declared in the from() option override any that are declared within substitutable expressions. If you specify a parameter that does not appear in your model, mlexp exits with an error. If you specify a matrix, the values must be in the same order in which the parameters are declared in your model.

constraints(numlist), collinear; see [R] estimation options.

+-------------+ ----+ Derivatives +------------------------------------------------------

derivative(/name = dexp) specifies the derivative of the observation-level log-likelihood function with respect to parameter name. If you wish to specify analytic derivatives, you must specify derivative() for each parameter in your model.

dexp uses the same substitutable expression syntax as is used to specify the log-likelihood function. If you declare a linear combination in the log-likelihood function, you provide the derivative for the linear combination; mlexp then applies the chain rule for you. See the final example below.

If you do not specify the derivative() option, mlexp calculates derivatives numerically.

+-----------+ ----+ SE/Robust +--------------------------------------------------------

vce(vcetype) specifies the type of standard error reported, which includes types that are derived from asymptotic theory (oim, opg), that are robust to some kinds of misspecification (robust), that allow for intragroup correlation (cluster clustvar), and that use bootstrap or jackknife methods (bootstrap, jackknife); see [R] vce_option.

+-----------+ ----+ Reporting +--------------------------------------------------------

level(#); see [R] estimation options.

title(string) specifies an optional title that will be displayed just above the table of parameter estimates.

title2(string) specifies an optional subtitle that will be displayed between the title specified in title() and the table of parameter estimates. If title2() is specified but title() is not, then title2() has the same effect as title().

display_options: noci, nopvalues, noomitted, vsquish, noemptycells, baselevels, allbaselevels, nofvlabel, fvwrap(#), fvwrapon(style), cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R] estimation options.

+--------------+ ----+ Maximization +-----------------------------------------------------

maximize_options: difficult, technique(algorithm_spec), iterate(#), [no]log, trace, gradient, showstep, hessian, showtolerance, tolerance(#), ltolerance(#), nrtolerance(#), and nonrtolerance; see [R] maximize. These options are seldom used.

The following options are available with mlexp but are not shown in the dialog box:

debug specifies that differences between the numerically computed gradient and the gradient computed from your derivative expression are reported at each iteration. This option is only allowed with the derivative() option.

coeflegend; see [R] estimation options.

Remarks

mlexp allows you to fit models via maximum likelihood estimation without doing any programming. Instead, you express your log-likelihood function by using a substitutable expression, a mathematical expression that uses curly braces to differentiate parameters from variables. There are three rules to follow when defining substitutable expressions:

1. Parameters of the model are bound in curly braces: {b0}, {param}, etc. Parameter names must follow the same conventions as variable names; see [U] 11.3 Naming conventions

2. Initial values for parameters are given by including an equal sign and the initial value inside the curly braces: {b0=1}, {param=3.571}, etc.

3. Linear combinations of variables can be included using the notation {lc:varlist}: {xb: mpg price weight _cons}, {score: w x z}, etc. Parameters of linear combinations are initialized to zero.

Substitutable expressions can include any mathematical expression involving scalars and variables. See operator and exp for more information on expressions.

Examples

Classical linear regression . sysuse auto . mlexp (ln(normalden(mpg, {b0} + {b1}*gear_ratio, {sigma})))

Same as above, constraining sigma to be positive . mlexp (ln(normalden(mpg, {xb:gear_ratio _cons}, exp({lnsigma})))) . nlcom exp(_b[/lnsigma])

Probit regression with a linear combination of regressors . mlexp (ln(cond(foreign==1, normal({xb:gear_ratio turn _cons}), normal(-1*({xb:})))))

Same as above, using Greene's (2018, 742, fn. 16) auxiliary variable coded -1 for failures and +1 for successes . generate int q = 2*(foreign==1) - 1 . mlexp (ln(normal(q*({xb:gear_ratio turn _cons}))))

Same as above, specifying derivatives . mlexp (ln(normal(q*({xb:gear_ratio turn _cons})))), deriv(/xb = q*normalden({xb:})/normal(q*({xb:})))

Stored results

mlexp stores the following in e():

Scalars e(N) number of observations e(k) number of parameters e(k_aux) number of ancillary parameters e(k_eq) number of equations in e(b) e(k_eq_model) number of equations in overall model test e(df_m) model degrees of freedom e(ll) log likelihood e(N_clust) number of clusters e(rank) rank of e(V) e(ic) number of iterations e(rc) return code e(converged) 1 if converged, 0 otherwise

Macros e(cmd) mlexp e(cmdline) command as typed e(lexp) likelihood expression e(wtype) weight type e(wexp) weight expression e(usrtitle) user-specified title e(usrtitle2) user-specified secondary title e(clustvar) name of cluster variable e(vce) vcetype specified in vce() e(vcetype) title used to label Std. Err. e(params) names of parameters e(hasderiv) yes, if derivative() is specified e(d_j) derivative expression for parameter j e(rhs) contents of variables() e(opt) type of optimization e(ml_method) type of ml method e(technique) maximization technique e(singularHmethod) m-marquardt or hybrid; method used when Hessian is singular (1) e(crittype) optimization criterion (1) e(properties) b V e(estat_cmd) program used to implement estat e(predict) program used to implement predict e(marginsok) predictions allowed by margins e(marginsnotok) predictions disallowed by margins e(marginsprop) signals to the margins command e(asbalanced) factor variables fvset as asbalanced e(asobserved) factor variables fvset as asobserved

Matrices e(b) coefficient vector e(Cns) constraints matrix e(ilog) iteration log (up to 20 iterations) e(init) initial values e(gradient) gradient vector e(V) variance-covariance matrix of the estimators e(V_modelbased) model-based variance

Functions e(sample) marks estimation sample -------------------- 1. Type ereturn list, all to view these results; see [P] return.

Reference

Greene, W. H. 2018. Econometric Analysis. 8th ed. New York: Pearson.


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index